32 #include <linux/if_arp.h>
33 #include <linux/slab.h>
37 #include <linux/atalk.h>
42 #include <linux/export.h>
79 static int unresolved_count;
103 static void __aarp_send_query(
struct aarp_entry *
a)
105 static unsigned char aarp_eth_multicast[
ETH_ALEN] =
106 { 0x09, 0x00, 0x07, 0xFF, 0xFF, 0xFF };
123 skb_reset_network_header(skb);
124 skb_reset_transport_header(skb);
170 skb_reset_network_header(skb);
171 skb_reset_transport_header(skb);
213 static unsigned char aarp_eth_multicast[
ETH_ALEN] =
214 { 0x09, 0x00, 0x07, 0xFF, 0xFF, 0xFF };
221 skb_reset_network_header(skb);
222 skb_reset_transport_header(skb);
257 static void __aarp_expire_timer(
struct aarp_entry **
n)
276 static void __aarp_kick(
struct aarp_entry **n)
287 __aarp_send_query(*n);
303 if ((*n)->dev == dev) {
312 static void aarp_expire_timeout(
unsigned long unused)
319 __aarp_expire_timer(&resolved[ct]);
320 __aarp_kick(&unresolved[ct]);
321 __aarp_expire_timer(&unresolved[ct]);
322 __aarp_expire_timer(&proxies[ct]);
338 if (!net_eq(dev_net(dev), &
init_net))
345 __aarp_expire_device(&resolved[ct], dev);
346 __aarp_expire_device(&unresolved[ct], dev);
347 __aarp_expire_device(&proxies[ct], dev);
356 static void __aarp_expire_all(
struct aarp_entry **n)
368 static void aarp_purge(
void)
374 __aarp_expire_all(&resolved[ct]);
375 __aarp_expire_all(&unresolved[ct]);
376 __aarp_expire_all(&proxies[ct]);
423 a = __aarp_find_entry(proxies[hash], dev, sa);
435 struct aarp_entry *a = __aarp_find_entry(proxies[hash], dev, sa);
437 return a ? sa :
NULL;
444 static void aarp_send_probe_phase1(
struct atalk_iface *iface)
470 aarp_send_probe_phase1(atif);
504 entry = aarp_alloc();
517 hash = sa->
s_node % (AARP_HASH_SIZE - 1);
522 aarp_send_probe(atif->
dev, sa);
550 static char ddp_eth_multicast[
ETH_ALEN] =
551 { 0x09, 0x00, 0x07, 0xFF, 0xFF, 0xFF };
555 skb_reset_network_header(skb);
608 hash = sa->
s_node % (AARP_HASH_SIZE - 1);
618 a = __aarp_find_entry(resolved[hash], dev, sa);
628 a = __aarp_find_entry(unresolved[hash], dev, sa);
649 unresolved[
hash] =
a;
653 __aarp_send_query(a);
660 if (unresolved_count == 1)
711 list = &((*list)->next);
728 if (!net_eq(dev_net(dev), &
init_net))
742 if (function < AARP_REQUEST || function >
AARP_PROBE ||
755 ifa = atalk_find_dev(dev);
771 a = __aarp_find_entry(proxies[hash], dev, &da);
784 if (!unresolved_count)
788 a = __aarp_find_entry(unresolved[hash], dev, &sa);
789 if (!a || dev != a->
dev)
794 __aarp_resolved(&unresolved[hash], a, hash);
795 if (!unresolved_count)
819 ma = __aarp_proxy_find(dev, &sa);
834 a = __aarp_find_entry(resolved[sa.s_node %
835 (AARP_HASH_SIZE - 1)],
851 if (sa.s_node != ma->
s_node)
854 if (sa.s_net && ma->
s_net && sa.s_net != ma->
s_net)
862 aarp_send_reply(dev, ma, &sa, ea->
hw_src);
876 .notifier_call = aarp_device_event,
879 static unsigned char aarp_snap_id[] = { 0x00, 0x00, 0x00, 0x80, 0xF3 };
900 __aarp_expire_device(&resolved[ct], dev);
901 __aarp_expire_device(&unresolved[ct], dev);
902 __aarp_expire_device(&proxies[ct], dev);
908 #ifdef CONFIG_PROC_FS
909 struct aarp_iter_state {
920 static struct aarp_entry *iter_next(
struct aarp_iter_state *iter, loff_t *
pos)
922 int ct = iter->bucket;
928 while(ct < AARP_HASH_SIZE) {
929 for (entry = table[ct];
entry; entry = entry->
next) {
930 if (!pos || ++off == *pos) {
939 if (table == resolved) {
944 if (table == unresolved) {
952 static void *aarp_seq_start(
struct seq_file *seq, loff_t *pos)
955 struct aarp_iter_state *iter =
seq->private;
958 iter->table = resolved;
964 static void *aarp_seq_next(
struct seq_file *seq,
void *
v, loff_t *pos)
967 struct aarp_iter_state *iter = seq->
private;
973 entry = iter_next(iter,
NULL);
976 else if (entry->
next)
982 entry = iter_next(iter,
NULL);
987 static void aarp_seq_stop(
struct seq_file *seq,
void *v)
993 static const char *dt2str(
unsigned long ticks)
997 sprintf(buf,
"%ld.%02ld", ticks /
HZ, ((ticks %
HZ) * 100 ) / HZ);
1002 static int aarp_seq_show(
struct seq_file *seq,
void *v)
1004 struct aarp_iter_state *iter = seq->
private;
1010 "Address Interface Hardware Address"
1011 " Expires LastSend Retry Status\n");
1016 entry->
dev ? entry->
dev->name :
"????");
1019 dt2str((
long)entry->
expires_at - (
long)now));
1020 if (iter->table == unresolved)
1027 (iter->table == resolved) ?
"resolved"
1028 : (iter->table == unresolved) ?
"unresolved"
1029 : (iter->table == proxies) ?
"proxies"
1036 .
start = aarp_seq_start,
1037 .next = aarp_seq_next,
1038 .stop = aarp_seq_stop,
1039 .show = aarp_seq_show,
1045 sizeof(
struct aarp_iter_state));
1050 .open = aarp_seq_open,