3333#include <linux/slab.h>
3434#include <net/route.h> /* for struct rtable and routing */
3535#include <net/icmp.h> /* icmp_send */
36+ #include <net/arp.h>
3637#include <linux/param.h> /* for HZ */
3738#include <linux/uaccess.h>
3839#include <asm/byteorder.h> /* for htons etc. */
@@ -287,70 +288,23 @@ static const struct neigh_ops clip_neigh_ops = {
287288static int clip_constructor (struct neighbour * neigh )
288289{
289290 struct atmarp_entry * entry = neighbour_priv (neigh );
290- struct net_device * dev = neigh -> dev ;
291- struct in_device * in_dev ;
292- struct neigh_parms * parms ;
293291
294- pr_debug ("(neigh %p, entry %p)\n" , neigh , entry );
295- neigh -> type = inet_addr_type (& init_net , * ((__be32 * ) neigh -> primary_key ));
296- if (neigh -> type != RTN_UNICAST )
292+ if (neigh -> tbl -> family != AF_INET )
297293 return - EINVAL ;
298294
299- rcu_read_lock ();
300- in_dev = __in_dev_get_rcu (dev );
301- if (!in_dev ) {
302- rcu_read_unlock ();
295+ if (neigh -> type != RTN_UNICAST )
303296 return - EINVAL ;
304- }
305-
306- parms = in_dev -> arp_parms ;
307- __neigh_parms_put (neigh -> parms );
308- neigh -> parms = neigh_parms_clone (parms );
309- rcu_read_unlock ();
310297
298+ neigh -> nud_state = NUD_NONE ;
311299 neigh -> ops = & clip_neigh_ops ;
312- neigh -> output = neigh -> nud_state & NUD_VALID ?
313- neigh -> ops -> connected_output : neigh -> ops -> output ;
300+ neigh -> output = neigh -> ops -> output ;
314301 entry -> neigh = neigh ;
315302 entry -> vccs = NULL ;
316303 entry -> expires = jiffies - 1 ;
304+
317305 return 0 ;
318306}
319307
320- static u32 clip_hash (const void * pkey , const struct net_device * dev , __u32 rnd )
321- {
322- return jhash_2words (* (u32 * ) pkey , dev -> ifindex , rnd );
323- }
324-
325- static struct neigh_table clip_tbl = {
326- .family = AF_INET ,
327- .key_len = 4 ,
328- .hash = clip_hash ,
329- .constructor = clip_constructor ,
330- .id = "clip_arp_cache" ,
331-
332- /* parameters are copied from ARP ... */
333- .parms = {
334- .tbl = & clip_tbl ,
335- .base_reachable_time = 30 * HZ ,
336- .retrans_time = 1 * HZ ,
337- .gc_staletime = 60 * HZ ,
338- .reachable_time = 30 * HZ ,
339- .delay_probe_time = 5 * HZ ,
340- .queue_len_bytes = 64 * 1024 ,
341- .ucast_probes = 3 ,
342- .mcast_probes = 3 ,
343- .anycast_delay = 1 * HZ ,
344- .proxy_delay = (8 * HZ ) / 10 ,
345- .proxy_qlen = 64 ,
346- .locktime = 1 * HZ ,
347- },
348- .gc_interval = 30 * HZ ,
349- .gc_thresh1 = 128 ,
350- .gc_thresh2 = 512 ,
351- .gc_thresh3 = 1024 ,
352- };
353-
354308/* @@@ copy bh locking from arp.c -- need to bh-enable atm code before */
355309
356310/*
@@ -508,7 +462,7 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip)
508462 rt = ip_route_output (& init_net , ip , 0 , 1 , 0 );
509463 if (IS_ERR (rt ))
510464 return PTR_ERR (rt );
511- neigh = __neigh_lookup (& clip_tbl , & ip , rt -> dst .dev , 1 );
465+ neigh = __neigh_lookup (& arp_tbl , & ip , rt -> dst .dev , 1 );
512466 ip_rt_put (rt );
513467 if (!neigh )
514468 return - ENOMEM ;
@@ -529,7 +483,8 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip)
529483}
530484
531485static const struct net_device_ops clip_netdev_ops = {
532- .ndo_start_xmit = clip_start_xmit ,
486+ .ndo_start_xmit = clip_start_xmit ,
487+ .ndo_neigh_construct = clip_constructor ,
533488};
534489
535490static void clip_setup (struct net_device * dev )
@@ -590,10 +545,8 @@ static int clip_device_event(struct notifier_block *this, unsigned long event,
590545 if (!net_eq (dev_net (dev ), & init_net ))
591546 return NOTIFY_DONE ;
592547
593- if (event == NETDEV_UNREGISTER ) {
594- neigh_ifdown (& clip_tbl , dev );
548+ if (event == NETDEV_UNREGISTER )
595549 return NOTIFY_DONE ;
596- }
597550
598551 /* ignore non-CLIP devices */
599552 if (dev -> type != ARPHRD_ATM || dev -> netdev_ops != & clip_netdev_ops )
@@ -867,14 +820,17 @@ static void *clip_seq_sub_iter(struct neigh_seq_state *_state,
867820{
868821 struct clip_seq_state * state = (struct clip_seq_state * )_state ;
869822
823+ if (n -> dev -> type != ARPHRD_ATM )
824+ return NULL ;
825+
870826 return clip_seq_vcc_walk (state , neighbour_priv (n ), pos );
871827}
872828
873829static void * clip_seq_start (struct seq_file * seq , loff_t * pos )
874830{
875831 struct clip_seq_state * state = seq -> private ;
876832 state -> ns .neigh_sub_iter = clip_seq_sub_iter ;
877- return neigh_seq_start (seq , pos , & clip_tbl , NEIGH_SEQ_NEIGH_ONLY );
833+ return neigh_seq_start (seq , pos , & arp_tbl , NEIGH_SEQ_NEIGH_ONLY );
878834}
879835
880836static int clip_seq_show (struct seq_file * seq , void * v )
@@ -920,9 +876,6 @@ static void atm_clip_exit_noproc(void);
920876
921877static int __init atm_clip_init (void )
922878{
923- neigh_table_init_no_netlink (& clip_tbl );
924-
925- clip_tbl_hook = & clip_tbl ;
926879 register_atm_ioctl (& clip_ioctl_ops );
927880 register_netdevice_notifier (& clip_dev_notifier );
928881 register_inetaddr_notifier (& clip_inet_notifier );
@@ -959,24 +912,13 @@ static void atm_clip_exit_noproc(void)
959912 */
960913 del_timer_sync (& idle_timer );
961914
962- /* Next, purge the table, so that the device
963- * unregister loop below does not hang due to
964- * device references remaining in the table.
965- */
966- neigh_ifdown (& clip_tbl , NULL );
967-
968915 dev = clip_devs ;
969916 while (dev ) {
970917 next = PRIV (dev )-> next ;
971918 unregister_netdev (dev );
972919 free_netdev (dev );
973920 dev = next ;
974921 }
975-
976- /* Now it is safe to fully shutdown whole table. */
977- neigh_table_clear (& clip_tbl );
978-
979- clip_tbl_hook = NULL ;
980922}
981923
982924static void __exit atm_clip_exit (void )
0 commit comments