27 #include <linux/net.h>
28 #include <linux/module.h>
29 #include <linux/socket.h>
30 #include <linux/if_arp.h>
31 #include <linux/slab.h>
32 #include <linux/if_ether.h>
35 #include <linux/string.h>
51 static int dn_neigh_construct(
struct neighbour *);
62 static const struct neigh_ops dn_long_ops = {
64 .error_report = dn_long_error_report,
65 .output = dn_long_output,
66 .connected_output = dn_long_output,
72 static const struct neigh_ops dn_short_ops = {
74 .error_report = dn_short_error_report,
75 .output = dn_short_output,
76 .connected_output = dn_short_output,
82 static const struct neigh_ops dn_phase3_ops = {
84 .error_report = dn_short_error_report,
85 .output = dn_phase3_output,
86 .connected_output = dn_phase3_output,
89 static u32 dn_neigh_hash(
const void *
pkey,
93 return jhash_2words(*(
__u16 *)pkey, 0, hash_rnd[0]);
98 .entry_size =
sizeof(
struct dn_neigh),
100 .
hash = dn_neigh_hash,
101 .constructor = dn_neigh_construct,
102 .
id =
"dn_neigh_cache",
105 .base_reachable_time = 30 *
HZ,
106 .retrans_time = 1 *
HZ,
107 .gc_staletime = 60 *
HZ,
108 .reachable_time = 30 *
HZ,
109 .delay_probe_time = 5 *
HZ,
110 .queue_len_bytes = 64*1024,
119 .gc_interval = 30 *
HZ,
125 static int dn_neigh_construct(
struct neighbour *neigh)
145 __neigh_parms_put(neigh->
parms);
146 neigh->
parms = neigh_parms_clone(parms);
149 neigh->
ops = &dn_long_ops;
151 neigh->
ops = &dn_short_ops;
155 neigh->
ops = &dn_phase3_ops;
158 neigh->
output = neigh->
ops->connected_output;
163 dn_dn2eth(neigh->
ha, dn->
addr);
201 static int dn_neigh_output_packet(
struct sk_buff *
skb)
213 seq = read_seqbegin(&neigh->
ha_lock);
215 neigh->
ha, mac_addr, skb->
len);
216 }
while (read_seqretry(&neigh->
ha_lock, seq));
236 if (skb_headroom(skb) < headroom) {
264 skb_reset_network_header(skb);
267 neigh->
dev, dn_neigh_output_packet);
279 if (skb_headroom(skb) < headroom) {
300 skb_reset_network_header(skb);
303 neigh->
dev, dn_neigh_output_packet);
318 if (skb_headroom(skb) < headroom) {
339 skb_reset_network_header(skb);
342 neigh->
dev, dn_neigh_output_packet);
372 src = dn_eth2dn(msg->
id);
374 neigh = __neigh_lookup(&dn_neigh_table, &
src, skb->
dev, 1);
408 dn_db->
router = neigh_clone(neigh);
411 neigh_release(
xchg(&dn_db->
router, neigh_clone(neigh)));
415 neigh_release(neigh);
432 src = dn_eth2dn(msg->
id);
434 neigh = __neigh_lookup(&dn_neigh_table, &
src, skb->
dev, 1);
454 neigh_release(neigh);
461 static char *dn_find_slot(
char *base,
int max,
int priority)
468 for(i = 0; i <
max; i++) {
469 if (!min || (*base < *min))
477 return (*min < priority) ? (min - 6) :
NULL;
487 static void neigh_elist_cb(
struct neighbour *neigh,
void *_info)
506 dn_dn2eth(s->
rs, dn->
addr);
529 #ifdef CONFIG_PROC_FS
531 static inline void dn_neigh_format_entry(
struct seq_file *seq,
538 seq_printf(seq,
"%-7s %s%s%s %02x %02d %07ld %-8s\n",
546 (dn->
n.dev) ? dn->
n.dev->name :
"?");
550 static int dn_neigh_seq_show(
struct seq_file *seq,
void *
v)
553 seq_puts(seq,
"Addr Flags State Use Blksize Dev\n");
555 dn_neigh_format_entry(seq, v);
561 static void *dn_neigh_seq_start(
struct seq_file *seq, loff_t *
pos)
568 .
start = dn_neigh_seq_start,
571 .show = dn_neigh_seq_show,
582 .open = dn_neigh_seq_open,