neighbour.c (4ec93edb14fe5fdee9fae6335f2cbba204627eac) | neighbour.c (c376222960ae91d5ffb9197ee36771aaed1d9f90) |
---|---|
1/* 2 * Generic address resolution entity 3 * 4 * Authors: 5 * Pedro Roque <roque@di.fc.ul.pt> 6 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 7 * 8 * This program is free software; you can redistribute it and/or --- 237 unchanged lines hidden (view full) --- 246 if (entries >= tbl->gc_thresh3 || 247 (entries >= tbl->gc_thresh2 && 248 time_after(now, tbl->last_flush + 5 * HZ))) { 249 if (!neigh_forced_gc(tbl) && 250 entries >= tbl->gc_thresh3) 251 goto out_entries; 252 } 253 | 1/* 2 * Generic address resolution entity 3 * 4 * Authors: 5 * Pedro Roque <roque@di.fc.ul.pt> 6 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 7 * 8 * This program is free software; you can redistribute it and/or --- 237 unchanged lines hidden (view full) --- 246 if (entries >= tbl->gc_thresh3 || 247 (entries >= tbl->gc_thresh2 && 248 time_after(now, tbl->last_flush + 5 * HZ))) { 249 if (!neigh_forced_gc(tbl) && 250 entries >= tbl->gc_thresh3) 251 goto out_entries; 252 } 253 |
254 n = kmem_cache_alloc(tbl->kmem_cachep, GFP_ATOMIC); | 254 n = kmem_cache_zalloc(tbl->kmem_cachep, GFP_ATOMIC); |
255 if (!n) 256 goto out_entries; 257 | 255 if (!n) 256 goto out_entries; 257 |
258 memset(n, 0, tbl->entry_size); 259 | |
260 skb_queue_head_init(&n->arp_queue); 261 rwlock_init(&n->lock); 262 n->updated = n->used = now; 263 n->nud_state = NUD_NONE; 264 n->output = neigh_blackhole; 265 n->parms = neigh_parms_clone(&tbl->parms); 266 init_timer(&n->timer); 267 n->timer.function = neigh_timer_handler; --- 72 unchanged lines hidden (view full) --- 340} 341 342struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey, 343 struct net_device *dev) 344{ 345 struct neighbour *n; 346 int key_len = tbl->key_len; 347 u32 hash_val = tbl->hash(pkey, dev); | 258 skb_queue_head_init(&n->arp_queue); 259 rwlock_init(&n->lock); 260 n->updated = n->used = now; 261 n->nud_state = NUD_NONE; 262 n->output = neigh_blackhole; 263 n->parms = neigh_parms_clone(&tbl->parms); 264 init_timer(&n->timer); 265 n->timer.function = neigh_timer_handler; --- 72 unchanged lines hidden (view full) --- 338} 339 340struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey, 341 struct net_device *dev) 342{ 343 struct neighbour *n; 344 int key_len = tbl->key_len; 345 u32 hash_val = tbl->hash(pkey, dev); |
348 | 346 |
349 NEIGH_CACHE_STAT_INC(tbl, lookups); 350 351 read_lock_bh(&tbl->lock); 352 for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { 353 if (dev == n->dev && !memcmp(n->primary_key, pkey, key_len)) { 354 neigh_hold(n); 355 NEIGH_CACHE_STAT_INC(tbl, hits); 356 break; --- 325 unchanged lines hidden (view full) --- 682 continue; 683 } 684 write_unlock(&n->lock); 685 686next_elt: 687 np = &n->next; 688 } 689 | 347 NEIGH_CACHE_STAT_INC(tbl, lookups); 348 349 read_lock_bh(&tbl->lock); 350 for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { 351 if (dev == n->dev && !memcmp(n->primary_key, pkey, key_len)) { 352 neigh_hold(n); 353 NEIGH_CACHE_STAT_INC(tbl, hits); 354 break; --- 325 unchanged lines hidden (view full) --- 680 continue; 681 } 682 write_unlock(&n->lock); 683 684next_elt: 685 np = &n->next; 686 } 687 |
690 /* Cycle through all hash buckets every base_reachable_time/2 ticks. 691 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 692 * base_reachable_time. | 688 /* Cycle through all hash buckets every base_reachable_time/2 ticks. 689 * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 690 * base_reachable_time. |
693 */ 694 expire = tbl->parms.base_reachable_time >> 1; 695 expire /= (tbl->hash_mask + 1); 696 if (!expire) 697 expire = 1; 698 699 if (expire>HZ) 700 mod_timer(&tbl->gc_timer, round_jiffies(now + expire)); --- 38 unchanged lines hidden (view full) --- 739 if (!(state & NUD_IN_TIMER)) { 740#ifndef CONFIG_SMP 741 printk(KERN_WARNING "neigh: timer & !nud_in_timer\n"); 742#endif 743 goto out; 744 } 745 746 if (state & NUD_REACHABLE) { | 691 */ 692 expire = tbl->parms.base_reachable_time >> 1; 693 expire /= (tbl->hash_mask + 1); 694 if (!expire) 695 expire = 1; 696 697 if (expire>HZ) 698 mod_timer(&tbl->gc_timer, round_jiffies(now + expire)); --- 38 unchanged lines hidden (view full) --- 737 if (!(state & NUD_IN_TIMER)) { 738#ifndef CONFIG_SMP 739 printk(KERN_WARNING "neigh: timer & !nud_in_timer\n"); 740#endif 741 goto out; 742 } 743 744 if (state & NUD_REACHABLE) { |
747 if (time_before_eq(now, | 745 if (time_before_eq(now, |
748 neigh->confirmed + neigh->parms->reachable_time)) { 749 NEIGH_PRINTK2("neigh %p is still alive.\n", neigh); 750 next = neigh->confirmed + neigh->parms->reachable_time; 751 } else if (time_before_eq(now, 752 neigh->used + neigh->parms->delay_probe_time)) { 753 NEIGH_PRINTK2("neigh %p is delayed.\n", neigh); 754 neigh->nud_state = NUD_DELAY; 755 neigh->updated = jiffies; 756 neigh_suspect(neigh); 757 next = now + neigh->parms->delay_probe_time; 758 } else { 759 NEIGH_PRINTK2("neigh %p is suspected.\n", neigh); 760 neigh->nud_state = NUD_STALE; 761 neigh->updated = jiffies; 762 neigh_suspect(neigh); 763 notify = 1; 764 } 765 } else if (state & NUD_DELAY) { | 746 neigh->confirmed + neigh->parms->reachable_time)) { 747 NEIGH_PRINTK2("neigh %p is still alive.\n", neigh); 748 next = neigh->confirmed + neigh->parms->reachable_time; 749 } else if (time_before_eq(now, 750 neigh->used + neigh->parms->delay_probe_time)) { 751 NEIGH_PRINTK2("neigh %p is delayed.\n", neigh); 752 neigh->nud_state = NUD_DELAY; 753 neigh->updated = jiffies; 754 neigh_suspect(neigh); 755 next = now + neigh->parms->delay_probe_time; 756 } else { 757 NEIGH_PRINTK2("neigh %p is suspected.\n", neigh); 758 neigh->nud_state = NUD_STALE; 759 neigh->updated = jiffies; 760 neigh_suspect(neigh); 761 notify = 1; 762 } 763 } else if (state & NUD_DELAY) { |
766 if (time_before_eq(now, | 764 if (time_before_eq(now, |
767 neigh->confirmed + neigh->parms->delay_probe_time)) { 768 NEIGH_PRINTK2("neigh %p is now reachable.\n", neigh); 769 neigh->nud_state = NUD_REACHABLE; 770 neigh->updated = jiffies; 771 neigh_connect(neigh); 772 notify = 1; 773 next = neigh->confirmed + neigh->parms->reachable_time; 774 } else { --- 69 unchanged lines hidden (view full) --- 844 845 write_lock_bh(&neigh->lock); 846 847 rc = 0; 848 if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE)) 849 goto out_unlock_bh; 850 851 now = jiffies; | 765 neigh->confirmed + neigh->parms->delay_probe_time)) { 766 NEIGH_PRINTK2("neigh %p is now reachable.\n", neigh); 767 neigh->nud_state = NUD_REACHABLE; 768 neigh->updated = jiffies; 769 neigh_connect(neigh); 770 notify = 1; 771 next = neigh->confirmed + neigh->parms->reachable_time; 772 } else { --- 69 unchanged lines hidden (view full) --- 842 843 write_lock_bh(&neigh->lock); 844 845 rc = 0; 846 if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE)) 847 goto out_unlock_bh; 848 849 now = jiffies; |
852 | 850 |
853 if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) { 854 if (neigh->parms->mcast_probes + neigh->parms->app_probes) { 855 atomic_set(&neigh->probes, neigh->parms->ucast_probes); 856 neigh->nud_state = NUD_INCOMPLETE; 857 neigh->updated = jiffies; 858 neigh_hold(neigh); 859 neigh_add_timer(neigh, now + 1); 860 } else { --- 51 unchanged lines hidden (view full) --- 912 913/* Generic update routine. 914 -- lladdr is new lladdr or NULL, if it is not supplied. 915 -- new is new state. 916 -- flags 917 NEIGH_UPDATE_F_OVERRIDE allows to override existing lladdr, 918 if it is different. 919 NEIGH_UPDATE_F_WEAK_OVERRIDE will suspect existing "connected" | 851 if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) { 852 if (neigh->parms->mcast_probes + neigh->parms->app_probes) { 853 atomic_set(&neigh->probes, neigh->parms->ucast_probes); 854 neigh->nud_state = NUD_INCOMPLETE; 855 neigh->updated = jiffies; 856 neigh_hold(neigh); 857 neigh_add_timer(neigh, now + 1); 858 } else { --- 51 unchanged lines hidden (view full) --- 910 911/* Generic update routine. 912 -- lladdr is new lladdr or NULL, if it is not supplied. 913 -- new is new state. 914 -- flags 915 NEIGH_UPDATE_F_OVERRIDE allows to override existing lladdr, 916 if it is different. 917 NEIGH_UPDATE_F_WEAK_OVERRIDE will suspect existing "connected" |
920 lladdr instead of overriding it | 918 lladdr instead of overriding it |
921 if it is different. 922 It also allows to retain current state 923 if lladdr is unchanged. 924 NEIGH_UPDATE_F_ADMIN means that the change is administrative. 925 | 919 if it is different. 920 It also allows to retain current state 921 if lladdr is unchanged. 922 NEIGH_UPDATE_F_ADMIN means that the change is administrative. 923 |
926 NEIGH_UPDATE_F_OVERRIDE_ISROUTER allows to override existing | 924 NEIGH_UPDATE_F_OVERRIDE_ISROUTER allows to override existing |
927 NTF_ROUTER flag. 928 NEIGH_UPDATE_F_ISROUTER indicates if the neighbour is known as 929 a router. 930 931 Caller MUST hold reference count on the entry. 932 */ 933 934int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, --- 6 unchanged lines hidden (view full) --- 941 int update_isrouter = 0; 942 943 write_lock_bh(&neigh->lock); 944 945 dev = neigh->dev; 946 old = neigh->nud_state; 947 err = -EPERM; 948 | 925 NTF_ROUTER flag. 926 NEIGH_UPDATE_F_ISROUTER indicates if the neighbour is known as 927 a router. 928 929 Caller MUST hold reference count on the entry. 930 */ 931 932int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, --- 6 unchanged lines hidden (view full) --- 939 int update_isrouter = 0; 940 941 write_lock_bh(&neigh->lock); 942 943 dev = neigh->dev; 944 old = neigh->nud_state; 945 err = -EPERM; 946 |
949 if (!(flags & NEIGH_UPDATE_F_ADMIN) && | 947 if (!(flags & NEIGH_UPDATE_F_ADMIN) && |
950 (old & (NUD_NOARP | NUD_PERMANENT))) 951 goto out; 952 953 if (!(new & NUD_VALID)) { 954 neigh_del_timer(neigh); 955 if (old & NUD_CONNECTED) 956 neigh_suspect(neigh); 957 neigh->nud_state = new; --- 7 unchanged lines hidden (view full) --- 965 /* First case: device needs no address. */ 966 lladdr = neigh->ha; 967 } else if (lladdr) { 968 /* The second case: if something is already cached 969 and a new address is proposed: 970 - compare new & old 971 - if they are different, check override flag 972 */ | 948 (old & (NUD_NOARP | NUD_PERMANENT))) 949 goto out; 950 951 if (!(new & NUD_VALID)) { 952 neigh_del_timer(neigh); 953 if (old & NUD_CONNECTED) 954 neigh_suspect(neigh); 955 neigh->nud_state = new; --- 7 unchanged lines hidden (view full) --- 963 /* First case: device needs no address. */ 964 lladdr = neigh->ha; 965 } else if (lladdr) { 966 /* The second case: if something is already cached 967 and a new address is proposed: 968 - compare new & old 969 - if they are different, check override flag 970 */ |
973 if ((old & NUD_VALID) && | 971 if ((old & NUD_VALID) && |
974 !memcmp(lladdr, neigh->ha, dev->addr_len)) 975 lladdr = neigh->ha; 976 } else { 977 /* No address is supplied; if we know something, 978 use it, otherwise discard the request. 979 */ 980 err = -EINVAL; 981 if (!(old & NUD_VALID)) --- 27 unchanged lines hidden (view full) --- 1009 new = old; 1010 } 1011 } 1012 1013 if (new != old) { 1014 neigh_del_timer(neigh); 1015 if (new & NUD_IN_TIMER) { 1016 neigh_hold(neigh); | 972 !memcmp(lladdr, neigh->ha, dev->addr_len)) 973 lladdr = neigh->ha; 974 } else { 975 /* No address is supplied; if we know something, 976 use it, otherwise discard the request. 977 */ 978 err = -EINVAL; 979 if (!(old & NUD_VALID)) --- 27 unchanged lines hidden (view full) --- 1007 new = old; 1008 } 1009 } 1010 1011 if (new != old) { 1012 neigh_del_timer(neigh); 1013 if (new & NUD_IN_TIMER) { 1014 neigh_hold(neigh); |
1017 neigh_add_timer(neigh, (jiffies + 1018 ((new & NUD_REACHABLE) ? | 1015 neigh_add_timer(neigh, (jiffies + 1016 ((new & NUD_REACHABLE) ? |
1019 neigh->parms->reachable_time : 1020 0))); 1021 } 1022 neigh->nud_state = new; 1023 } 1024 1025 if (lladdr != neigh->ha) { 1026 memcpy(&neigh->ha, lladdr, dev->addr_len); --- 45 unchanged lines hidden (view full) --- 1072 1073struct neighbour *neigh_event_ns(struct neigh_table *tbl, 1074 u8 *lladdr, void *saddr, 1075 struct net_device *dev) 1076{ 1077 struct neighbour *neigh = __neigh_lookup(tbl, saddr, dev, 1078 lladdr || !dev->addr_len); 1079 if (neigh) | 1017 neigh->parms->reachable_time : 1018 0))); 1019 } 1020 neigh->nud_state = new; 1021 } 1022 1023 if (lladdr != neigh->ha) { 1024 memcpy(&neigh->ha, lladdr, dev->addr_len); --- 45 unchanged lines hidden (view full) --- 1070 1071struct neighbour *neigh_event_ns(struct neigh_table *tbl, 1072 u8 *lladdr, void *saddr, 1073 struct net_device *dev) 1074{ 1075 struct neighbour *neigh = __neigh_lookup(tbl, saddr, dev, 1076 lladdr || !dev->addr_len); 1077 if (neigh) |
1080 neigh_update(neigh, lladdr, NUD_STALE, | 1078 neigh_update(neigh, lladdr, NUD_STALE, |
1081 NEIGH_UPDATE_F_OVERRIDE); 1082 return neigh; 1083} 1084 1085static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst, 1086 __be16 protocol) 1087{ 1088 struct hh_cache *hh; --- 35 unchanged lines hidden (view full) --- 1124int neigh_compat_output(struct sk_buff *skb) 1125{ 1126 struct net_device *dev = skb->dev; 1127 1128 __skb_pull(skb, skb->nh.raw - skb->data); 1129 1130 if (dev->hard_header && 1131 dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, | 1079 NEIGH_UPDATE_F_OVERRIDE); 1080 return neigh; 1081} 1082 1083static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst, 1084 __be16 protocol) 1085{ 1086 struct hh_cache *hh; --- 35 unchanged lines hidden (view full) --- 1122int neigh_compat_output(struct sk_buff *skb) 1123{ 1124 struct net_device *dev = skb->dev; 1125 1126 __skb_pull(skb, skb->nh.raw - skb->data); 1127 1128 if (dev->hard_header && 1129 dev->hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, |
1132 skb->len) < 0 && | 1130 skb->len) < 0 && |
1133 dev->rebuild_header(skb)) 1134 return 0; 1135 1136 return dev_queue_xmit(skb); 1137} 1138 1139/* Slow and careful. */ 1140 --- 203 unchanged lines hidden (view full) --- 1344 if (!tbl->kmem_cachep) 1345 tbl->kmem_cachep = 1346 kmem_cache_create(tbl->id, tbl->entry_size, 0, 1347 SLAB_HWCACHE_ALIGN|SLAB_PANIC, 1348 NULL, NULL); 1349 tbl->stats = alloc_percpu(struct neigh_statistics); 1350 if (!tbl->stats) 1351 panic("cannot create neighbour cache statistics"); | 1131 dev->rebuild_header(skb)) 1132 return 0; 1133 1134 return dev_queue_xmit(skb); 1135} 1136 1137/* Slow and careful. */ 1138 --- 203 unchanged lines hidden (view full) --- 1342 if (!tbl->kmem_cachep) 1343 tbl->kmem_cachep = 1344 kmem_cache_create(tbl->id, tbl->entry_size, 0, 1345 SLAB_HWCACHE_ALIGN|SLAB_PANIC, 1346 NULL, NULL); 1347 tbl->stats = alloc_percpu(struct neigh_statistics); 1348 if (!tbl->stats) 1349 panic("cannot create neighbour cache statistics"); |
1352 | 1350 |
1353#ifdef CONFIG_PROC_FS 1354 tbl->pde = create_proc_entry(tbl->id, 0, proc_net_stat); | 1351#ifdef CONFIG_PROC_FS 1352 tbl->pde = create_proc_entry(tbl->id, 0, proc_net_stat); |
1355 if (!tbl->pde) | 1353 if (!tbl->pde) |
1356 panic("cannot create neighbour proc dir entry"); 1357 tbl->pde->proc_fops = &neigh_stat_seq_fops; 1358 tbl->pde->data = tbl; 1359#endif 1360 1361 tbl->hash_mask = 1; 1362 tbl->hash_buckets = neigh_hash_alloc(tbl->hash_mask + 1); 1363 --- 198 unchanged lines hidden (view full) --- 1562 goto out_dev_put; 1563 1564 neigh = neigh_lookup(tbl, dst, dev); 1565 if (neigh == NULL) { 1566 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { 1567 err = -ENOENT; 1568 goto out_dev_put; 1569 } | 1354 panic("cannot create neighbour proc dir entry"); 1355 tbl->pde->proc_fops = &neigh_stat_seq_fops; 1356 tbl->pde->data = tbl; 1357#endif 1358 1359 tbl->hash_mask = 1; 1360 tbl->hash_buckets = neigh_hash_alloc(tbl->hash_mask + 1); 1361 --- 198 unchanged lines hidden (view full) --- 1560 goto out_dev_put; 1561 1562 neigh = neigh_lookup(tbl, dst, dev); 1563 if (neigh == NULL) { 1564 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { 1565 err = -ENOENT; 1566 goto out_dev_put; 1567 } |
1570 | 1568 |
1571 neigh = __neigh_lookup_errno(tbl, dst, dev); 1572 if (IS_ERR(neigh)) { 1573 err = PTR_ERR(neigh); 1574 goto out_dev_put; 1575 } 1576 } else { 1577 if (nlh->nlmsg_flags & NLM_F_EXCL) { 1578 err = -EEXIST; --- 160 unchanged lines hidden (view full) --- 1739 1740 read_unlock_bh(&tbl->lock); 1741 return nlmsg_end(skb, nlh); 1742errout: 1743 read_unlock_bh(&tbl->lock); 1744 nlmsg_cancel(skb, nlh); 1745 return -EMSGSIZE; 1746} | 1569 neigh = __neigh_lookup_errno(tbl, dst, dev); 1570 if (IS_ERR(neigh)) { 1571 err = PTR_ERR(neigh); 1572 goto out_dev_put; 1573 } 1574 } else { 1575 if (nlh->nlmsg_flags & NLM_F_EXCL) { 1576 err = -EEXIST; --- 160 unchanged lines hidden (view full) --- 1737 1738 read_unlock_bh(&tbl->lock); 1739 return nlmsg_end(skb, nlh); 1740errout: 1741 read_unlock_bh(&tbl->lock); 1742 nlmsg_cancel(skb, nlh); 1743 return -EMSGSIZE; 1744} |
1747 | 1745 |
1748static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl, 1749 int ifindex) 1750{ 1751 struct neigh_parms *p; | 1746static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl, 1747 int ifindex) 1748{ 1749 struct neigh_parms *p; |
1752 | 1750 |
1753 for (p = &tbl->parms; p; p = p->next) 1754 if ((p->dev && p->dev->ifindex == ifindex) || 1755 (!p->dev && !ifindex)) 1756 return p; 1757 1758 return NULL; 1759} 1760 --- 49 unchanged lines hidden (view full) --- 1810 break; 1811 } 1812 1813 if (tbl == NULL) { 1814 err = -ENOENT; 1815 goto errout_locked; 1816 } 1817 | 1751 for (p = &tbl->parms; p; p = p->next) 1752 if ((p->dev && p->dev->ifindex == ifindex) || 1753 (!p->dev && !ifindex)) 1754 return p; 1755 1756 return NULL; 1757} 1758 --- 49 unchanged lines hidden (view full) --- 1808 break; 1809 } 1810 1811 if (tbl == NULL) { 1812 err = -ENOENT; 1813 goto errout_locked; 1814 } 1815 |
1818 /* | 1816 /* |
1819 * We acquire tbl->lock to be nice to the periodic timers and 1820 * make sure they always see a consistent set of values. 1821 */ 1822 write_lock_bh(&tbl->lock); 1823 1824 if (tb[NDTA_PARMS]) { 1825 struct nlattr *tbp[NDTPA_MAX+1]; 1826 struct neigh_parms *p; --- 491 unchanged lines hidden (view full) --- 2318static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos) 2319{ 2320 struct proc_dir_entry *pde = seq->private; 2321 struct neigh_table *tbl = pde->data; 2322 int cpu; 2323 2324 if (*pos == 0) 2325 return SEQ_START_TOKEN; | 1817 * We acquire tbl->lock to be nice to the periodic timers and 1818 * make sure they always see a consistent set of values. 1819 */ 1820 write_lock_bh(&tbl->lock); 1821 1822 if (tb[NDTA_PARMS]) { 1823 struct nlattr *tbp[NDTPA_MAX+1]; 1824 struct neigh_parms *p; --- 491 unchanged lines hidden (view full) --- 2316static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos) 2317{ 2318 struct proc_dir_entry *pde = seq->private; 2319 struct neigh_table *tbl = pde->data; 2320 int cpu; 2321 2322 if (*pos == 0) 2323 return SEQ_START_TOKEN; |
2326 | 2324 |
2327 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) { 2328 if (!cpu_possible(cpu)) 2329 continue; 2330 *pos = cpu+1; 2331 return per_cpu_ptr(tbl->stats, cpu); 2332 } 2333 return NULL; 2334} --- 291 unchanged lines hidden (view full) --- 2626 .ctl_name = CTL_NET, 2627 .procname = "net", 2628 .mode = 0555, 2629 }, 2630 }, 2631}; 2632 2633int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | 2325 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) { 2326 if (!cpu_possible(cpu)) 2327 continue; 2328 *pos = cpu+1; 2329 return per_cpu_ptr(tbl->stats, cpu); 2330 } 2331 return NULL; 2332} --- 291 unchanged lines hidden (view full) --- 2624 .ctl_name = CTL_NET, 2625 .procname = "net", 2626 .mode = 0555, 2627 }, 2628 }, 2629}; 2630 2631int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, |
2634 int p_id, int pdev_id, char *p_name, | 2632 int p_id, int pdev_id, char *p_name, |
2635 proc_handler *handler, ctl_handler *strategy) 2636{ 2637 struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template, 2638 sizeof(*t), GFP_KERNEL); 2639 const char *dev_name_source = NULL; 2640 char *dev_name = NULL; 2641 int err = 0; 2642 --- 15 unchanged lines hidden (view full) --- 2658 if (dev) { 2659 dev_name_source = dev->name; 2660 t->neigh_dev[0].ctl_name = dev->ifindex; 2661 t->neigh_vars[12].procname = NULL; 2662 t->neigh_vars[13].procname = NULL; 2663 t->neigh_vars[14].procname = NULL; 2664 t->neigh_vars[15].procname = NULL; 2665 } else { | 2633 proc_handler *handler, ctl_handler *strategy) 2634{ 2635 struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template, 2636 sizeof(*t), GFP_KERNEL); 2637 const char *dev_name_source = NULL; 2638 char *dev_name = NULL; 2639 int err = 0; 2640 --- 15 unchanged lines hidden (view full) --- 2656 if (dev) { 2657 dev_name_source = dev->name; 2658 t->neigh_dev[0].ctl_name = dev->ifindex; 2659 t->neigh_vars[12].procname = NULL; 2660 t->neigh_vars[13].procname = NULL; 2661 t->neigh_vars[14].procname = NULL; 2662 t->neigh_vars[15].procname = NULL; 2663 } else { |
2666 dev_name_source = t->neigh_dev[0].procname; | 2664 dev_name_source = t->neigh_dev[0].procname; |
2667 t->neigh_vars[12].data = (int *)(p + 1); 2668 t->neigh_vars[13].data = (int *)(p + 1) + 1; 2669 t->neigh_vars[14].data = (int *)(p + 1) + 2; 2670 t->neigh_vars[15].data = (int *)(p + 1) + 3; 2671 } 2672 2673 t->neigh_vars[16].data = &p->retrans_time; 2674 t->neigh_vars[17].data = &p->base_reachable_time; --- 18 unchanged lines hidden (view full) --- 2693 } 2694 2695 dev_name = kstrdup(dev_name_source, GFP_KERNEL); 2696 if (!dev_name) { 2697 err = -ENOBUFS; 2698 goto free; 2699 } 2700 | 2665 t->neigh_vars[12].data = (int *)(p + 1); 2666 t->neigh_vars[13].data = (int *)(p + 1) + 1; 2667 t->neigh_vars[14].data = (int *)(p + 1) + 2; 2668 t->neigh_vars[15].data = (int *)(p + 1) + 3; 2669 } 2670 2671 t->neigh_vars[16].data = &p->retrans_time; 2672 t->neigh_vars[17].data = &p->base_reachable_time; --- 18 unchanged lines hidden (view full) --- 2691 } 2692 2693 dev_name = kstrdup(dev_name_source, GFP_KERNEL); 2694 if (!dev_name) { 2695 err = -ENOBUFS; 2696 goto free; 2697 } 2698 |
2701 t->neigh_dev[0].procname = dev_name; | 2699 t->neigh_dev[0].procname = dev_name; |
2702 2703 t->neigh_neigh_dir[0].ctl_name = pdev_id; 2704 2705 t->neigh_proto_dir[0].procname = p_name; 2706 t->neigh_proto_dir[0].ctl_name = p_id; 2707 2708 t->neigh_dev[0].child = t->neigh_vars; 2709 t->neigh_neigh_dir[0].child = t->neigh_dev; --- 63 unchanged lines hidden --- | 2700 2701 t->neigh_neigh_dir[0].ctl_name = pdev_id; 2702 2703 t->neigh_proto_dir[0].procname = p_name; 2704 t->neigh_proto_dir[0].ctl_name = p_id; 2705 2706 t->neigh_dev[0].child = t->neigh_vars; 2707 t->neigh_neigh_dir[0].child = t->neigh_dev; --- 63 unchanged lines hidden --- |