Blame view
net/decnet/dn_neigh.c
15.6 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 |
/* * DECnet An implementation of the DECnet protocol suite for the LINUX * operating system. DECnet is implemented using the BSD Socket * interface as the means of communication with the user level. * |
429eb0fae [NET] DECNET: Fix... |
7 |
* DECnet Neighbour Functions (Adjacency Database and |
1da177e4c Linux-2.6.12-rc2 |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
* On-Ethernet Cache) * * Author: Steve Whitehouse <SteveW@ACM.org> * * * Changes: * Steve Whitehouse : Fixed router listing routine * Steve Whitehouse : Added error_report functions * Steve Whitehouse : Added default router detection * Steve Whitehouse : Hop counts in outgoing messages * Steve Whitehouse : Fixed src/dst in outgoing messages so * forwarding now stands a good chance of * working. * Steve Whitehouse : Fixed neighbour states (for now anyway). * Steve Whitehouse : Made error_report functions dummies. This * is not the right place to return skbs. * Steve Whitehouse : Convert to seq_file * */ |
1da177e4c Linux-2.6.12-rc2 |
27 28 29 30 |
#include <linux/net.h> #include <linux/module.h> #include <linux/socket.h> #include <linux/if_arp.h> |
5a0e3ad6a include cleanup: ... |
31 |
#include <linux/slab.h> |
1da177e4c Linux-2.6.12-rc2 |
32 33 34 35 36 37 38 39 40 |
#include <linux/if_ether.h> #include <linux/init.h> #include <linux/proc_fs.h> #include <linux/string.h> #include <linux/netfilter_decnet.h> #include <linux/spinlock.h> #include <linux/seq_file.h> #include <linux/rcupdate.h> #include <linux/jhash.h> |
60063497a atomic: use <linu... |
41 |
#include <linux/atomic.h> |
457c4cbc5 [NET]: Make /proc... |
42 |
#include <net/net_namespace.h> |
1da177e4c Linux-2.6.12-rc2 |
43 44 45 46 47 48 49 |
#include <net/neighbour.h> #include <net/dst.h> #include <net/flow.h> #include <net/dn.h> #include <net/dn_dev.h> #include <net/dn_neigh.h> #include <net/dn_route.h> |
1da177e4c Linux-2.6.12-rc2 |
50 |
static int dn_neigh_construct(struct neighbour *); |
aaa4e7040 DECnet: Only use ... |
51 52 |
static void dn_neigh_error_report(struct neighbour *, struct sk_buff *); static int dn_neigh_output(struct neighbour *neigh, struct sk_buff *skb); |
1da177e4c Linux-2.6.12-rc2 |
53 54 |
/* |
aaa4e7040 DECnet: Only use ... |
55 |
* Operations for adding the link layer header. |
1da177e4c Linux-2.6.12-rc2 |
56 |
*/ |
aaa4e7040 DECnet: Only use ... |
57 |
static const struct neigh_ops dn_neigh_ops = { |
1da177e4c Linux-2.6.12-rc2 |
58 |
.family = AF_DECnet, |
aaa4e7040 DECnet: Only use ... |
59 60 61 |
.error_report = dn_neigh_error_report, .output = dn_neigh_output, .connected_output = dn_neigh_output, |
1da177e4c Linux-2.6.12-rc2 |
62 |
}; |
d6bf78171 net neigh: RCU co... |
63 64 |
static u32 dn_neigh_hash(const void *pkey, const struct net_device *dev, |
2c2aba6c5 ipv6: Use univers... |
65 |
__u32 *hash_rnd) |
d6bf78171 net neigh: RCU co... |
66 |
{ |
2c2aba6c5 ipv6: Use univers... |
67 |
return jhash_2words(*(__u16 *)pkey, 0, hash_rnd[0]); |
d6bf78171 net neigh: RCU co... |
68 |
} |
60395a20f neigh: Factor out... |
69 70 71 72 |
static bool dn_key_eq(const struct neighbour *neigh, const void *pkey) { return neigh_key_eq16(neigh, pkey); } |
1da177e4c Linux-2.6.12-rc2 |
73 74 |
struct neigh_table dn_neigh_table = { .family = PF_DECnet, |
daaba4fa1 net neighbour, de... |
75 |
.entry_size = NEIGH_ENTRY_SIZE(sizeof(struct dn_neigh)), |
c4ea94ab3 [DECnet]: Endian ... |
76 |
.key_len = sizeof(__le16), |
bdf53c584 neigh: Don't requ... |
77 |
.protocol = cpu_to_be16(ETH_P_DNA_RT), |
1da177e4c Linux-2.6.12-rc2 |
78 |
.hash = dn_neigh_hash, |
60395a20f neigh: Factor out... |
79 |
.key_eq = dn_key_eq, |
1da177e4c Linux-2.6.12-rc2 |
80 81 82 83 |
.constructor = dn_neigh_construct, .id = "dn_neigh_cache", .parms ={ .tbl = &dn_neigh_table, |
1f9248e56 neigh: convert pa... |
84 85 86 87 88 89 90 91 92 |
.reachable_time = 30 * HZ, .data = { [NEIGH_VAR_MCAST_PROBES] = 0, [NEIGH_VAR_UCAST_PROBES] = 0, [NEIGH_VAR_APP_PROBES] = 0, [NEIGH_VAR_RETRANS_TIME] = 1 * HZ, [NEIGH_VAR_BASE_REACHABLE_TIME] = 30 * HZ, [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, [NEIGH_VAR_GC_STALETIME] = 60 * HZ, |
eaa72dc47 neigh: increase q... |
93 |
[NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_MAX, |
1f9248e56 neigh: convert pa... |
94 95 96 97 98 |
[NEIGH_VAR_PROXY_QLEN] = 0, [NEIGH_VAR_ANYCAST_DELAY] = 0, [NEIGH_VAR_PROXY_DELAY] = 0, [NEIGH_VAR_LOCKTIME] = 1 * HZ, }, |
1da177e4c Linux-2.6.12-rc2 |
99 100 101 102 103 104 |
}, .gc_interval = 30 * HZ, .gc_thresh1 = 128, .gc_thresh2 = 512, .gc_thresh3 = 1024, }; |
1da177e4c Linux-2.6.12-rc2 |
105 106 107 |
static int dn_neigh_construct(struct neighbour *neigh) { struct net_device *dev = neigh->dev; |
f92ceb01c DECnet: Use conta... |
108 |
struct dn_neigh *dn = container_of(neigh, struct dn_neigh, n); |
1da177e4c Linux-2.6.12-rc2 |
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
struct dn_dev *dn_db; struct neigh_parms *parms; rcu_read_lock(); dn_db = rcu_dereference(dev->dn_ptr); if (dn_db == NULL) { rcu_read_unlock(); return -EINVAL; } parms = dn_db->neigh_parms; if (!parms) { rcu_read_unlock(); return -EINVAL; } __neigh_parms_put(neigh->parms); neigh->parms = neigh_parms_clone(parms); |
1f07247de [DECNET]: Fix RCU... |
127 |
rcu_read_unlock(); |
1da177e4c Linux-2.6.12-rc2 |
128 |
|
aaa4e7040 DECnet: Only use ... |
129 |
neigh->ops = &dn_neigh_ops; |
1da177e4c Linux-2.6.12-rc2 |
130 131 132 133 134 135 136 137 |
neigh->nud_state = NUD_NOARP; neigh->output = neigh->ops->connected_output; if ((dev->type == ARPHRD_IPGRE) || (dev->flags & IFF_POINTOPOINT)) memcpy(neigh->ha, dev->broadcast, dev->addr_len); else if ((dev->type == ARPHRD_ETHER) || (dev->type == ARPHRD_LOOPBACK)) dn_dn2eth(neigh->ha, dn->addr); else { |
e87cc4728 net: Convert net_... |
138 139 140 |
net_dbg_ratelimited("Trying to create neigh for hw %d ", dev->type); |
1da177e4c Linux-2.6.12-rc2 |
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
return -EINVAL; } /* * Make an estimate of the remote block size by assuming that its * two less then the device mtu, which it true for ethernet (and * other things which support long format headers) since there is * an extra length field (of 16 bits) which isn't part of the * ethernet headers and which the DECnet specs won't admit is part * of the DECnet routing headers either. * * If we over estimate here its no big deal, the NSP negotiations * will prevent us from sending packets which are too large for the * remote node to handle. In any case this figure is normally updated * by a hello message in most cases. */ dn->blksize = dev->mtu - 2; return 0; } |
aaa4e7040 DECnet: Only use ... |
161 |
static void dn_neigh_error_report(struct neighbour *neigh, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
162 |
{ |
aaa4e7040 DECnet: Only use ... |
163 164 |
printk(KERN_DEBUG "dn_neigh_error_report: called "); |
1da177e4c Linux-2.6.12-rc2 |
165 166 |
kfree_skb(skb); } |
aaa4e7040 DECnet: Only use ... |
167 |
static int dn_neigh_output(struct neighbour *neigh, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
168 |
{ |
adf30907d net: skb->dst acc... |
169 |
struct dst_entry *dst = skb_dst(skb); |
1da177e4c Linux-2.6.12-rc2 |
170 |
struct dn_route *rt = (struct dn_route *)dst; |
1da177e4c Linux-2.6.12-rc2 |
171 172 |
struct net_device *dev = neigh->dev; char mac_addr[ETH_ALEN]; |
3329bdfc4 decnet: Add missi... |
173 174 |
unsigned int seq; int err; |
1da177e4c Linux-2.6.12-rc2 |
175 176 |
dn_dn2eth(mac_addr, rt->rt_local_src); |
3329bdfc4 decnet: Add missi... |
177 178 179 180 181 182 183 184 185 186 187 188 189 |
do { seq = read_seqbegin(&neigh->ha_lock); err = dev_hard_header(skb, dev, ntohs(skb->protocol), neigh->ha, mac_addr, skb->len); } while (read_seqretry(&neigh->ha_lock, seq)); if (err >= 0) err = dev_queue_xmit(skb); else { kfree_skb(skb); err = -EINVAL; } return err; |
1da177e4c Linux-2.6.12-rc2 |
190 |
} |
0c4b51f00 netfilter: Pass n... |
191 |
static int dn_neigh_output_packet(struct net *net, struct sock *sk, struct sk_buff *skb) |
aaa4e7040 DECnet: Only use ... |
192 193 194 195 196 197 198 199 200 201 202 |
{ struct dst_entry *dst = skb_dst(skb); struct dn_route *rt = (struct dn_route *)dst; struct neighbour *neigh = rt->n; return neigh->output(neigh, skb); } /* * For talking to broadcast devices: Ethernet & PPP */ |
7026b1ddb netfilter: Pass s... |
203 204 |
static int dn_long_output(struct neighbour *neigh, struct sock *sk, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
205 |
{ |
1da177e4c Linux-2.6.12-rc2 |
206 207 208 209 210 211 212 213 214 215 |
struct net_device *dev = neigh->dev; int headroom = dev->hard_header_len + sizeof(struct dn_long_packet) + 3; unsigned char *data; struct dn_long_packet *lp; struct dn_skb_cb *cb = DN_SKB_CB(skb); if (skb_headroom(skb) < headroom) { struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom); if (skb2 == NULL) { |
e87cc4728 net: Convert net_... |
216 217 |
net_crit_ratelimited("dn_long_output: no memory "); |
1da177e4c Linux-2.6.12-rc2 |
218 219 220 |
kfree_skb(skb); return -ENOBUFS; } |
5d0ba55b6 net: use consume_... |
221 |
consume_skb(skb); |
1da177e4c Linux-2.6.12-rc2 |
222 |
skb = skb2; |
e87cc4728 net: Convert net_... |
223 224 |
net_info_ratelimited("dn_long_output: Increasing headroom "); |
1da177e4c Linux-2.6.12-rc2 |
225 226 227 228 |
} data = skb_push(skb, sizeof(struct dn_long_packet) + 3); lp = (struct dn_long_packet *)(data+3); |
c4106aa88 decnet: remove pr... |
229 |
*((__le16 *)data) = cpu_to_le16(skb->len - 2); |
1da177e4c Linux-2.6.12-rc2 |
230 231 232 233 |
*(data + 2) = 1 | DN_RT_F_PF; /* Padding */ lp->msgflg = DN_RT_PKT_LONG|(cb->rt_flags&(DN_RT_F_IE|DN_RT_F_RQR|DN_RT_F_RTS)); lp->d_area = lp->d_subarea = 0; |
c4ea94ab3 [DECnet]: Endian ... |
234 |
dn_dn2eth(lp->d_id, cb->dst); |
1da177e4c Linux-2.6.12-rc2 |
235 |
lp->s_area = lp->s_subarea = 0; |
c4ea94ab3 [DECnet]: Endian ... |
236 |
dn_dn2eth(lp->s_id, cb->src); |
1da177e4c Linux-2.6.12-rc2 |
237 238 239 240 |
lp->nl2 = 0; lp->visit_ct = cb->hops & 0x3f; lp->s_class = 0; lp->pt = 0; |
c1d2bbe1c [SK_BUFF]: Introd... |
241 |
skb_reset_network_header(skb); |
1da177e4c Linux-2.6.12-rc2 |
242 |
|
29a26a568 netfilter: Pass s... |
243 244 245 |
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, &init_net, sk, skb, NULL, neigh->dev, dn_neigh_output_packet); |
1da177e4c Linux-2.6.12-rc2 |
246 |
} |
aaa4e7040 DECnet: Only use ... |
247 248 249 |
/* * For talking to pointopoint and multidrop devices: DDCMP and X.25 */ |
7026b1ddb netfilter: Pass s... |
250 251 |
static int dn_short_output(struct neighbour *neigh, struct sock *sk, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
252 |
{ |
1da177e4c Linux-2.6.12-rc2 |
253 254 255 256 257 |
struct net_device *dev = neigh->dev; int headroom = dev->hard_header_len + sizeof(struct dn_short_packet) + 2; struct dn_short_packet *sp; unsigned char *data; struct dn_skb_cb *cb = DN_SKB_CB(skb); |
429eb0fae [NET] DECNET: Fix... |
258 259 260 |
if (skb_headroom(skb) < headroom) { struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom); if (skb2 == NULL) { |
e87cc4728 net: Convert net_... |
261 262 |
net_crit_ratelimited("dn_short_output: no memory "); |
429eb0fae [NET] DECNET: Fix... |
263 264 265 |
kfree_skb(skb); return -ENOBUFS; } |
5d0ba55b6 net: use consume_... |
266 |
consume_skb(skb); |
429eb0fae [NET] DECNET: Fix... |
267 |
skb = skb2; |
e87cc4728 net: Convert net_... |
268 269 |
net_info_ratelimited("dn_short_output: Increasing headroom "); |
429eb0fae [NET] DECNET: Fix... |
270 |
} |
1da177e4c Linux-2.6.12-rc2 |
271 272 |
data = skb_push(skb, sizeof(struct dn_short_packet) + 2); |
c4106aa88 decnet: remove pr... |
273 |
*((__le16 *)data) = cpu_to_le16(skb->len - 2); |
1da177e4c Linux-2.6.12-rc2 |
274 275 276 277 278 279 |
sp = (struct dn_short_packet *)(data+2); sp->msgflg = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS)); sp->dstnode = cb->dst; sp->srcnode = cb->src; sp->forward = cb->hops & 0x3f; |
c1d2bbe1c [SK_BUFF]: Introd... |
280 |
skb_reset_network_header(skb); |
1da177e4c Linux-2.6.12-rc2 |
281 |
|
29a26a568 netfilter: Pass s... |
282 283 284 |
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, &init_net, sk, skb, NULL, neigh->dev, dn_neigh_output_packet); |
1da177e4c Linux-2.6.12-rc2 |
285 286 287 |
} /* |
aaa4e7040 DECnet: Only use ... |
288 289 |
* For talking to DECnet phase III nodes * Phase 3 output is the same as short output, execpt that |
1da177e4c Linux-2.6.12-rc2 |
290 291 |
* it clears the area bits before transmission. */ |
7026b1ddb netfilter: Pass s... |
292 293 |
static int dn_phase3_output(struct neighbour *neigh, struct sock *sk, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
294 |
{ |
1da177e4c Linux-2.6.12-rc2 |
295 296 297 298 299 300 301 302 303 |
struct net_device *dev = neigh->dev; int headroom = dev->hard_header_len + sizeof(struct dn_short_packet) + 2; struct dn_short_packet *sp; unsigned char *data; struct dn_skb_cb *cb = DN_SKB_CB(skb); if (skb_headroom(skb) < headroom) { struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom); if (skb2 == NULL) { |
e87cc4728 net: Convert net_... |
304 305 |
net_crit_ratelimited("dn_phase3_output: no memory "); |
1da177e4c Linux-2.6.12-rc2 |
306 307 308 |
kfree_skb(skb); return -ENOBUFS; } |
5d0ba55b6 net: use consume_... |
309 |
consume_skb(skb); |
1da177e4c Linux-2.6.12-rc2 |
310 |
skb = skb2; |
e87cc4728 net: Convert net_... |
311 312 |
net_info_ratelimited("dn_phase3_output: Increasing headroom "); |
1da177e4c Linux-2.6.12-rc2 |
313 314 315 |
} data = skb_push(skb, sizeof(struct dn_short_packet) + 2); |
c4106aa88 decnet: remove pr... |
316 |
*((__le16 *)data) = cpu_to_le16(skb->len - 2); |
1da177e4c Linux-2.6.12-rc2 |
317 318 319 |
sp = (struct dn_short_packet *)(data + 2); sp->msgflg = DN_RT_PKT_SHORT|(cb->rt_flags&(DN_RT_F_RQR|DN_RT_F_RTS)); |
c4106aa88 decnet: remove pr... |
320 321 |
sp->dstnode = cb->dst & cpu_to_le16(0x03ff); sp->srcnode = cb->src & cpu_to_le16(0x03ff); |
1da177e4c Linux-2.6.12-rc2 |
322 |
sp->forward = cb->hops & 0x3f; |
c1d2bbe1c [SK_BUFF]: Introd... |
323 |
skb_reset_network_header(skb); |
1da177e4c Linux-2.6.12-rc2 |
324 |
|
29a26a568 netfilter: Pass s... |
325 326 327 |
return NF_HOOK(NFPROTO_DECNET, NF_DN_POST_ROUTING, &init_net, sk, skb, NULL, neigh->dev, dn_neigh_output_packet); |
1da177e4c Linux-2.6.12-rc2 |
328 |
} |
0c4b51f00 netfilter: Pass n... |
329 |
int dn_to_neigh_output(struct net *net, struct sock *sk, struct sk_buff *skb) |
aaa4e7040 DECnet: Only use ... |
330 331 332 333 |
{ struct dst_entry *dst = skb_dst(skb); struct dn_route *rt = (struct dn_route *) dst; struct neighbour *neigh = rt->n; |
f92ceb01c DECnet: Use conta... |
334 |
struct dn_neigh *dn = container_of(neigh, struct dn_neigh, n); |
aaa4e7040 DECnet: Only use ... |
335 336 337 338 339 340 341 342 343 344 345 346 347 |
struct dn_dev *dn_db; bool use_long; rcu_read_lock(); dn_db = rcu_dereference(neigh->dev->dn_ptr); if (dn_db == NULL) { rcu_read_unlock(); return -EINVAL; } use_long = dn_db->use_long; rcu_read_unlock(); if (dn->flags & DN_NDFLAG_P3) |
7026b1ddb netfilter: Pass s... |
348 |
return dn_phase3_output(neigh, sk, skb); |
aaa4e7040 DECnet: Only use ... |
349 |
if (use_long) |
7026b1ddb netfilter: Pass s... |
350 |
return dn_long_output(neigh, sk, skb); |
aaa4e7040 DECnet: Only use ... |
351 |
else |
7026b1ddb netfilter: Pass s... |
352 |
return dn_short_output(neigh, sk, skb); |
aaa4e7040 DECnet: Only use ... |
353 |
} |
1da177e4c Linux-2.6.12-rc2 |
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
/* * Unfortunately, the neighbour code uses the device in its hash * function, so we don't get any advantage from it. This function * basically does a neigh_lookup(), but without comparing the device * field. This is required for the On-Ethernet cache */ /* * Pointopoint link receives a hello message */ void dn_neigh_pointopoint_hello(struct sk_buff *skb) { kfree_skb(skb); } /* * Ethernet router hello message received */ |
0c4b51f00 netfilter: Pass n... |
372 |
int dn_neigh_router_hello(struct net *net, struct sock *sk, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
373 374 375 376 377 378 |
{ struct rtnode_hello_message *msg = (struct rtnode_hello_message *)skb->data; struct neighbour *neigh; struct dn_neigh *dn; struct dn_dev *dn_db; |
c4ea94ab3 [DECnet]: Endian ... |
379 |
__le16 src; |
1da177e4c Linux-2.6.12-rc2 |
380 |
|
c4ea94ab3 [DECnet]: Endian ... |
381 |
src = dn_eth2dn(msg->id); |
1da177e4c Linux-2.6.12-rc2 |
382 383 |
neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); |
f92ceb01c DECnet: Use conta... |
384 |
dn = container_of(neigh, struct dn_neigh, n); |
1da177e4c Linux-2.6.12-rc2 |
385 386 387 388 389 |
if (neigh) { write_lock(&neigh->lock); neigh->used = jiffies; |
fc766e4c4 decnet: RCU conve... |
390 |
dn_db = rcu_dereference(neigh->dev->dn_ptr); |
1da177e4c Linux-2.6.12-rc2 |
391 392 393 394 395 396 |
if (!(neigh->nud_state & NUD_PERMANENT)) { neigh->updated = jiffies; if (neigh->dev->type == ARPHRD_ETHER) memcpy(neigh->ha, ð_hdr(skb)->h_source, ETH_ALEN); |
c4106aa88 decnet: remove pr... |
397 |
dn->blksize = le16_to_cpu(msg->blksize); |
1da177e4c Linux-2.6.12-rc2 |
398 399 400 |
dn->priority = msg->priority; dn->flags &= ~DN_NDFLAG_P3; |
06f8fe11b decnet: Reduce sw... |
401 402 403 404 405 406 407 |
switch (msg->iinfo & DN_RT_INFO_TYPE) { case DN_RT_INFO_L1RT: dn->flags &=~DN_NDFLAG_R2; dn->flags |= DN_NDFLAG_R1; break; case DN_RT_INFO_L2RT: dn->flags |= DN_NDFLAG_R2; |
1da177e4c Linux-2.6.12-rc2 |
408 409 |
} } |
5062430c5 [DECNET]: Only us... |
410 |
/* Only use routers in our area */ |
c4106aa88 decnet: remove pr... |
411 |
if ((le16_to_cpu(src)>>10) == (le16_to_cpu((decnet_address))>>10)) { |
5062430c5 [DECNET]: Only us... |
412 413 414 415 416 417 |
if (!dn_db->router) { dn_db->router = neigh_clone(neigh); } else { if (msg->priority > ((struct dn_neigh *)dn_db->router)->priority) neigh_release(xchg(&dn_db->router, neigh_clone(neigh))); } |
1da177e4c Linux-2.6.12-rc2 |
418 419 420 421 422 423 424 425 426 427 428 429 |
} write_unlock(&neigh->lock); neigh_release(neigh); } kfree_skb(skb); return 0; } /* * Endnode hello message received */ |
0c4b51f00 netfilter: Pass n... |
430 |
int dn_neigh_endnode_hello(struct net *net, struct sock *sk, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
431 432 433 434 |
{ struct endnode_hello_message *msg = (struct endnode_hello_message *)skb->data; struct neighbour *neigh; struct dn_neigh *dn; |
c4ea94ab3 [DECnet]: Endian ... |
435 |
__le16 src; |
1da177e4c Linux-2.6.12-rc2 |
436 |
|
c4ea94ab3 [DECnet]: Endian ... |
437 |
src = dn_eth2dn(msg->id); |
1da177e4c Linux-2.6.12-rc2 |
438 439 |
neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); |
f92ceb01c DECnet: Use conta... |
440 |
dn = container_of(neigh, struct dn_neigh, n); |
1da177e4c Linux-2.6.12-rc2 |
441 442 443 444 445 446 447 448 449 450 451 452 |
if (neigh) { write_lock(&neigh->lock); neigh->used = jiffies; if (!(neigh->nud_state & NUD_PERMANENT)) { neigh->updated = jiffies; if (neigh->dev->type == ARPHRD_ETHER) memcpy(neigh->ha, ð_hdr(skb)->h_source, ETH_ALEN); dn->flags &= ~(DN_NDFLAG_R1 | DN_NDFLAG_R2); |
c4106aa88 decnet: remove pr... |
453 |
dn->blksize = le16_to_cpu(msg->blksize); |
1da177e4c Linux-2.6.12-rc2 |
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
dn->priority = 0; } write_unlock(&neigh->lock); neigh_release(neigh); } kfree_skb(skb); return 0; } static char *dn_find_slot(char *base, int max, int priority) { int i; unsigned char *min = NULL; base += 6; /* skip first id */ for(i = 0; i < max; i++) { if (!min || (*base < *min)) min = base; base += 7; /* find next priority */ } if (!min) return NULL; return (*min < priority) ? (min - 6) : NULL; } struct elist_cb_state { struct net_device *dev; unsigned char *ptr; unsigned char *rs; int t, n; }; static void neigh_elist_cb(struct neighbour *neigh, void *_info) { struct elist_cb_state *s = _info; |
1da177e4c Linux-2.6.12-rc2 |
494 495 496 497 |
struct dn_neigh *dn; if (neigh->dev != s->dev) return; |
f92ceb01c DECnet: Use conta... |
498 |
dn = container_of(neigh, struct dn_neigh, n); |
1da177e4c Linux-2.6.12-rc2 |
499 500 |
if (!(dn->flags & (DN_NDFLAG_R1|DN_NDFLAG_R2))) return; |
1da177e4c Linux-2.6.12-rc2 |
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
if (s->t == s->n) s->rs = dn_find_slot(s->ptr, s->n, dn->priority); else s->t++; if (s->rs == NULL) return; dn_dn2eth(s->rs, dn->addr); s->rs += 6; *(s->rs) = neigh->nud_state & NUD_CONNECTED ? 0x80 : 0x0; *(s->rs) |= dn->priority; s->rs++; } int dn_neigh_elist(struct net_device *dev, unsigned char *ptr, int n) { struct elist_cb_state state; state.dev = dev; state.t = 0; state.n = n; state.ptr = ptr; state.rs = ptr; neigh_for_each(&dn_neigh_table, neigh_elist_cb, &state); return state.t; } #ifdef CONFIG_PROC_FS static inline void dn_neigh_format_entry(struct seq_file *seq, struct neighbour *n) { |
f92ceb01c DECnet: Use conta... |
536 |
struct dn_neigh *dn = container_of(n, struct dn_neigh, n); |
1da177e4c Linux-2.6.12-rc2 |
537 538 539 540 541 |
char buf[DN_ASCBUF_LEN]; read_lock(&n->lock); seq_printf(seq, "%-7s %s%s%s %02x %02d %07ld %-8s ", |
c4106aa88 decnet: remove pr... |
542 |
dn_addr2asc(le16_to_cpu(dn->addr), buf), |
1da177e4c Linux-2.6.12-rc2 |
543 544 545 546 |
(dn->flags&DN_NDFLAG_R1) ? "1" : "-", (dn->flags&DN_NDFLAG_R2) ? "2" : "-", (dn->flags&DN_NDFLAG_P3) ? "3" : "-", dn->n.nud_state, |
9f2374301 net: convert neig... |
547 |
refcount_read(&dn->n.refcnt), |
1da177e4c Linux-2.6.12-rc2 |
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
dn->blksize, (dn->n.dev) ? dn->n.dev->name : "?"); read_unlock(&n->lock); } static int dn_neigh_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) { seq_puts(seq, "Addr Flags State Use Blksize Dev "); } else { dn_neigh_format_entry(seq, v); } return 0; } static void *dn_neigh_seq_start(struct seq_file *seq, loff_t *pos) { return neigh_seq_start(seq, pos, &dn_neigh_table, NEIGH_SEQ_NEIGH_ONLY); } |
56b3d975b [NET]: Make all i... |
570 |
static const struct seq_operations dn_neigh_seq_ops = { |
1da177e4c Linux-2.6.12-rc2 |
571 572 573 574 575 |
.start = dn_neigh_seq_start, .next = neigh_seq_next, .stop = neigh_seq_stop, .show = dn_neigh_seq_show, }; |
1da177e4c Linux-2.6.12-rc2 |
576 577 578 579 |
#endif void __init dn_neigh_init(void) { |
d7480fd3b neigh: remove dyn... |
580 |
neigh_table_init(NEIGH_DN_TABLE, &dn_neigh_table); |
c35063722 proc: introduce p... |
581 582 |
proc_create_net("decnet_neigh", 0444, init_net.proc_net, &dn_neigh_seq_ops, sizeof(struct neigh_seq_state)); |
1da177e4c Linux-2.6.12-rc2 |
583 584 585 586 |
} void __exit dn_neigh_cleanup(void) { |
ece31ffd5 net: proc: change... |
587 |
remove_proc_entry("decnet_neigh", init_net.proc_net); |
d7480fd3b neigh: remove dyn... |
588 |
neigh_table_clear(NEIGH_DN_TABLE, &dn_neigh_table); |
1da177e4c Linux-2.6.12-rc2 |
589 |
} |