Skip to content

Commit 32092ec

Browse files
committed
atm: clip: Use device neigh support on top of "arp_tbl".
Instead of instantiating an entire new neigh_table instance just for ATM handling, use the neigh device private facility. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent da6a8fa commit 32092ec

4 files changed

Lines changed: 16 additions & 90 deletions

File tree

‎include/net/atmclip.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,12 @@ struct atmarp_entry {
4141
struct neighbour *neigh; /* neighbour back-pointer */
4242
};
4343

44-
4544
#define PRIV(dev) ((struct clip_priv *) netdev_priv(dev))
4645

47-
4846
struct clip_priv {
4947
int number; /* for convenience ... */
5048
spinlock_t xoff_lock; /* ensures that pop is atomic (SMP) */
5149
struct net_device *next; /* next CLIP interface */
5250
};
5351

54-
55-
extern struct neigh_table *clip_tbl_hook;
56-
5752
#endif

‎net/atm/clip.c‎

Lines changed: 14 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
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 = {
287288
static 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

531485
static 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

535490
static 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

873829
static 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

880836
static int clip_seq_show(struct seq_file *seq, void *v)
@@ -920,9 +876,6 @@ static void atm_clip_exit_noproc(void);
920876

921877
static 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

982924
static void __exit atm_clip_exit(void)

‎net/ipv4/arp.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@
112112
#include <net/arp.h>
113113
#include <net/ax25.h>
114114
#include <net/netrom.h>
115-
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
116-
#include <net/atmclip.h>
117-
struct neigh_table *clip_tbl_hook;
118-
EXPORT_SYMBOL(clip_tbl_hook);
119-
#endif
120115

121116
#include <asm/system.h>
122117
#include <linux/uaccess.h>

‎net/ipv4/route.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
#ifdef CONFIG_SYSCTL
109109
#include <linux/sysctl.h>
110110
#endif
111-
#include <net/atmclip.h>
112111
#include <net/secure_seq.h>
113112

114113
#define RT_FL_TOS(oldflp4) \
@@ -1013,23 +1012,18 @@ static int slow_chain_length(const struct rtable *head)
10131012

10141013
static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, const void *daddr)
10151014
{
1016-
struct neigh_table *tbl = &arp_tbl;
10171015
static const __be32 inaddr_any = 0;
10181016
struct net_device *dev = dst->dev;
10191017
const __be32 *pkey = daddr;
10201018
struct neighbour *n;
10211019

1022-
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
1023-
if (dev->type == ARPHRD_ATM)
1024-
tbl = clip_tbl_hook;
1025-
#endif
10261020
if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
10271021
pkey = &inaddr_any;
10281022

1029-
n = __ipv4_neigh_lookup(tbl, dev, *(__force u32 *)pkey);
1023+
n = __ipv4_neigh_lookup(&arp_tbl, dev, *(__force u32 *)pkey);
10301024
if (n)
10311025
return n;
1032-
return neigh_create(tbl, pkey, dev);
1026+
return neigh_create(&arp_tbl, pkey, dev);
10331027
}
10341028

10351029
static int rt_bind_neighbour(struct rtable *rt)

0 commit comments

Comments
 (0)