Lines Matching +full:entry +full:- +full:address
1 // SPDX-License-Identifier: GPL-2.0-or-later
20 * Jaume Grau - flush caches on AARP_PROBE
21 * Rob Newberry - Added proxy AARP and AARP proc fs,
23 * Arnaldo C. Melo - don't mangle rx packets
46 * struct aarp_entry - AARP entry
50 * @expires_at: Entry expiry time
51 * @target_addr: DDP Address
53 * @hwaddr: Physical i/f address of target/router
55 * @next: Next entry in chain
89 skb_queue_purge(&a->packet_queue); in __aarp_expire()
94 * Send an aarp queue entry request
102 struct net_device *dev = a->dev; in __aarp_send_query()
104 int len = dev->hard_header_len + sizeof(*eah) + aarp_dl->header_length; in __aarp_send_query()
117 skb_reserve(skb, dev->hard_header_len + aarp_dl->header_length); in __aarp_send_query()
121 skb->protocol = htons(ETH_P_ATALK); in __aarp_send_query()
122 skb->dev = dev; in __aarp_send_query()
126 eah->hw_type = htons(AARP_HW_TYPE_ETHERNET); in __aarp_send_query()
127 eah->pa_type = htons(ETH_P_ATALK); in __aarp_send_query()
128 eah->hw_len = ETH_ALEN; in __aarp_send_query()
129 eah->pa_len = AARP_PA_ALEN; in __aarp_send_query()
130 eah->function = htons(AARP_REQUEST); in __aarp_send_query()
132 ether_addr_copy(eah->hw_src, dev->dev_addr); in __aarp_send_query()
134 eah->pa_src_zero = 0; in __aarp_send_query()
135 eah->pa_src_net = sat->s_net; in __aarp_send_query()
136 eah->pa_src_node = sat->s_node; in __aarp_send_query()
138 eth_zero_addr(eah->hw_dst); in __aarp_send_query()
140 eah->pa_dst_zero = 0; in __aarp_send_query()
141 eah->pa_dst_net = a->target_addr.s_net; in __aarp_send_query()
142 eah->pa_dst_node = a->target_addr.s_node; in __aarp_send_query()
145 aarp_dl->request(aarp_dl, skb, aarp_eth_multicast); in __aarp_send_query()
147 a->xmit_count++; in __aarp_send_query()
148 a->last_sent = jiffies; in __aarp_send_query()
157 int len = dev->hard_header_len + sizeof(*eah) + aarp_dl->header_length; in aarp_send_reply()
164 skb_reserve(skb, dev->hard_header_len + aarp_dl->header_length); in aarp_send_reply()
168 skb->protocol = htons(ETH_P_ATALK); in aarp_send_reply()
169 skb->dev = dev; in aarp_send_reply()
173 eah->hw_type = htons(AARP_HW_TYPE_ETHERNET); in aarp_send_reply()
174 eah->pa_type = htons(ETH_P_ATALK); in aarp_send_reply()
175 eah->hw_len = ETH_ALEN; in aarp_send_reply()
176 eah->pa_len = AARP_PA_ALEN; in aarp_send_reply()
177 eah->function = htons(AARP_REPLY); in aarp_send_reply()
179 ether_addr_copy(eah->hw_src, dev->dev_addr); in aarp_send_reply()
181 eah->pa_src_zero = 0; in aarp_send_reply()
182 eah->pa_src_net = us->s_net; in aarp_send_reply()
183 eah->pa_src_node = us->s_node; in aarp_send_reply()
186 eth_zero_addr(eah->hw_dst); in aarp_send_reply()
188 ether_addr_copy(eah->hw_dst, sha); in aarp_send_reply()
190 eah->pa_dst_zero = 0; in aarp_send_reply()
191 eah->pa_dst_net = them->s_net; in aarp_send_reply()
192 eah->pa_dst_node = them->s_node; in aarp_send_reply()
195 aarp_dl->request(aarp_dl, skb, sha); in aarp_send_reply()
206 int len = dev->hard_header_len + sizeof(*eah) + aarp_dl->header_length; in aarp_send_probe()
215 skb_reserve(skb, dev->hard_header_len + aarp_dl->header_length); in aarp_send_probe()
219 skb->protocol = htons(ETH_P_ATALK); in aarp_send_probe()
220 skb->dev = dev; in aarp_send_probe()
224 eah->hw_type = htons(AARP_HW_TYPE_ETHERNET); in aarp_send_probe()
225 eah->pa_type = htons(ETH_P_ATALK); in aarp_send_probe()
226 eah->hw_len = ETH_ALEN; in aarp_send_probe()
227 eah->pa_len = AARP_PA_ALEN; in aarp_send_probe()
228 eah->function = htons(AARP_PROBE); in aarp_send_probe()
230 ether_addr_copy(eah->hw_src, dev->dev_addr); in aarp_send_probe()
232 eah->pa_src_zero = 0; in aarp_send_probe()
233 eah->pa_src_net = us->s_net; in aarp_send_probe()
234 eah->pa_src_node = us->s_node; in aarp_send_probe()
236 eth_zero_addr(eah->hw_dst); in aarp_send_probe()
238 eah->pa_dst_zero = 0; in aarp_send_probe()
239 eah->pa_dst_net = us->s_net; in aarp_send_probe()
240 eah->pa_dst_node = us->s_node; in aarp_send_probe()
243 aarp_dl->request(aarp_dl, skb, aarp_eth_multicast); in aarp_send_probe()
258 if (time_after(jiffies, (*n)->expires_at)) { in __aarp_expire_timer()
260 *n = (*n)->next; in __aarp_expire_timer()
263 n = &((*n)->next); in __aarp_expire_timer()
277 if ((*n)->xmit_count >= sysctl_aarp_retransmit_limit) { in __aarp_kick()
279 *n = (*n)->next; in __aarp_kick()
283 n = &((*n)->next); in __aarp_kick()
298 if ((*n)->dev == dev) { in __aarp_expire_device()
300 *n = (*n)->next; in __aarp_expire_device()
303 n = &((*n)->next); in __aarp_expire_device()
357 *n = (*n)->next; in __aarp_expire_all()
362 /* Cleanup all hash chains -- module unloading */
377 * Create a new aarp entry. This must use GFP_ATOMIC because it
385 skb_queue_head_init(&a->packet_queue); in aarp_alloc()
390 * Find an entry. We might return an expired but not yet purged entry. We
400 if (list->target_addr.s_net == sat->s_net && in __aarp_find_entry()
401 list->target_addr.s_node == sat->s_node && in __aarp_find_entry()
402 list->dev == dev) in __aarp_find_entry()
404 list = list->next; in __aarp_find_entry()
413 int hash = sa->s_node % (AARP_HASH_SIZE - 1); in aarp_proxy_remove()
420 a->expires_at = jiffies - 1; in aarp_proxy_remove()
429 int hash = sa->s_node % (AARP_HASH_SIZE - 1); in __aarp_proxy_find()
443 const struct net_device_ops *ops = iface->dev->netdev_ops; in aarp_send_probe_phase1()
445 sa->sat_addr.s_node = iface->address.s_node; in aarp_send_probe_phase1()
446 sa->sat_addr.s_net = ntohs(iface->address.s_net); in aarp_send_probe_phase1()
449 if (!(ops->ndo_do_ioctl(iface->dev, &atreq, SIOCSIFADDR))) { in aarp_send_probe_phase1()
450 ops->ndo_do_ioctl(iface->dev, &atreq, SIOCGIFADDR); in aarp_send_probe_phase1()
451 if (iface->address.s_net != htons(sa->sat_addr.s_net) || in aarp_send_probe_phase1()
452 iface->address.s_node != sa->sat_addr.s_node) in aarp_send_probe_phase1()
453 iface->status |= ATIF_PROBE_FAIL; in aarp_send_probe_phase1()
455 iface->address.s_net = htons(sa->sat_addr.s_net); in aarp_send_probe_phase1()
456 iface->address.s_node = sa->sat_addr.s_node; in aarp_send_probe_phase1()
463 if (atif->dev->type == ARPHRD_LOCALTLK || in aarp_probe_network()
464 atif->dev->type == ARPHRD_PPP) in aarp_probe_network()
470 aarp_send_probe(atif->dev, &atif->address); in aarp_probe_network()
475 if (atif->status & ATIF_PROBE_FAIL) in aarp_probe_network()
483 int hash, retval = -EPROTONOSUPPORT; in aarp_proxy_probe_network()
484 struct aarp_entry *entry; in aarp_proxy_probe_network() local
491 if (atif->dev->type == ARPHRD_LOCALTLK || in aarp_proxy_probe_network()
492 atif->dev->type == ARPHRD_PPP) in aarp_proxy_probe_network()
496 * create a new AARP entry with the flags set to be published -- in aarp_proxy_probe_network()
499 entry = aarp_alloc(); in aarp_proxy_probe_network()
500 retval = -ENOMEM; in aarp_proxy_probe_network()
501 if (!entry) in aarp_proxy_probe_network()
504 entry->expires_at = -1; in aarp_proxy_probe_network()
505 entry->status = ATIF_PROBE; in aarp_proxy_probe_network()
506 entry->target_addr.s_node = sa->s_node; in aarp_proxy_probe_network()
507 entry->target_addr.s_net = sa->s_net; in aarp_proxy_probe_network()
508 entry->dev = atif->dev; in aarp_proxy_probe_network()
512 hash = sa->s_node % (AARP_HASH_SIZE - 1); in aarp_proxy_probe_network()
513 entry->next = proxies[hash]; in aarp_proxy_probe_network()
514 proxies[hash] = entry; in aarp_proxy_probe_network()
517 aarp_send_probe(atif->dev, sa); in aarp_proxy_probe_network()
524 if (entry->status & ATIF_PROBE_FAIL) in aarp_proxy_probe_network()
528 if (entry->status & ATIF_PROBE_FAIL) { in aarp_proxy_probe_network()
529 entry->expires_at = jiffies - 1; /* free the entry */ in aarp_proxy_probe_network()
530 retval = -EADDRINUSE; /* return network full */ in aarp_proxy_probe_network()
532 entry->status &= ~ATIF_PROBE; in aarp_proxy_probe_network()
553 if (dev->type == ARPHRD_LOCALTLK) { in aarp_send_ddp()
555 struct ddpehdr *ddp = (struct ddpehdr *)skb->data; in aarp_send_ddp()
565 if ((!ddp->deh_snet || at->s_net == ddp->deh_snet) && in aarp_send_ddp()
566 (!ddp->deh_dnet || at->s_net == ddp->deh_dnet)) { in aarp_send_ddp()
567 skb_pull(skb, sizeof(*ddp) - 4); in aarp_send_ddp()
574 *((__be16 *)skb->data) = htons(skb->len); in aarp_send_ddp()
583 skb->data[0] = sa->s_node; in aarp_send_ddp()
584 skb->data[1] = at->s_node; in aarp_send_ddp()
585 skb->data[2] = ft; in aarp_send_ddp()
586 skb->dev = dev; in aarp_send_ddp()
591 if (dev->type == ARPHRD_PPP) { in aarp_send_ddp()
592 skb->protocol = htons(ETH_P_PPPTALK); in aarp_send_ddp()
593 skb->dev = dev; in aarp_send_ddp()
598 if (dev->type != ARPHRD_ETHER) in aarp_send_ddp()
601 skb->dev = dev; in aarp_send_ddp()
602 skb->protocol = htons(ETH_P_ATALK); in aarp_send_ddp()
603 hash = sa->s_node % (AARP_HASH_SIZE - 1); in aarp_send_ddp()
605 /* Do we have a resolved entry? */ in aarp_send_ddp()
606 if (sa->s_node == ATADDR_BCAST) { in aarp_send_ddp()
608 ddp_dl->request(ddp_dl, skb, ddp_eth_multicast); in aarp_send_ddp()
615 if (a) { /* Return 1 and fill in the address */ in aarp_send_ddp()
616 a->expires_at = jiffies + (sysctl_aarp_expiry_time * 10); in aarp_send_ddp()
617 ddp_dl->request(ddp_dl, skb, a->hwaddr); in aarp_send_ddp()
622 /* Do we have an unresolved entry: This is the less common path */ in aarp_send_ddp()
625 skb_queue_tail(&a->packet_queue, skb); in aarp_send_ddp()
629 /* Allocate a new entry */ in aarp_send_ddp()
638 skb_queue_tail(&a->packet_queue, skb); in aarp_send_ddp()
639 a->expires_at = jiffies + sysctl_aarp_resolve_time; in aarp_send_ddp()
640 a->dev = dev; in aarp_send_ddp()
641 a->next = unresolved[hash]; in aarp_send_ddp()
642 a->target_addr = *sa; in aarp_send_ddp()
643 a->xmit_count = 0; in aarp_send_ddp()
647 /* Send an initial request for the address */ in aarp_send_ddp()
652 * unresolved entry to get added) in aarp_send_ddp()
666 if (skb->sk) in aarp_send_ddp()
667 skb->priority = READ_ONCE(skb->sk->sk_priority); in aarp_send_ddp()
680 * An entry in the aarp unresolved queue has become resolved. Send
692 unresolved_count--; in __aarp_resolved()
693 *list = a->next; in __aarp_resolved()
696 a->next = resolved[hash]; in __aarp_resolved()
700 while ((skb = skb_dequeue(&a->packet_queue)) != NULL) { in __aarp_resolved()
701 a->expires_at = jiffies + in __aarp_resolved()
703 ddp_dl->request(ddp_dl, skb, a->hwaddr); in __aarp_resolved()
706 list = &((*list)->next); in __aarp_resolved()
727 if (dev->type != ARPHRD_ETHER) in aarp_rcv()
734 function = ntohs(ea->function); in aarp_rcv()
738 ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN || in aarp_rcv()
739 ea->pa_src_zero || ea->pa_dst_zero) in aarp_rcv()
743 hash = ea->pa_src_node % (AARP_HASH_SIZE - 1); in aarp_rcv()
745 /* Build an address. */ in aarp_rcv()
746 sa.s_node = ea->pa_src_node; in aarp_rcv()
747 sa.s_net = ea->pa_src_net; in aarp_rcv()
754 if (ifa->status & ATIF_PROBE && in aarp_rcv()
755 ifa->address.s_node == ea->pa_dst_node && in aarp_rcv()
756 ifa->address.s_net == ea->pa_dst_net) { in aarp_rcv()
757 ifa->status |= ATIF_PROBE_FAIL; /* Fail the probe (in use) */ in aarp_rcv()
762 da.s_node = ea->pa_dst_node; in aarp_rcv()
763 da.s_net = ea->pa_dst_net; in aarp_rcv()
768 if (a && a->status & ATIF_PROBE) { in aarp_rcv()
769 a->status |= ATIF_PROBE_FAIL; in aarp_rcv()
772 * this address while we are probing this address in aarp_rcv()
782 /* Find the entry. */ in aarp_rcv()
784 if (!a || dev != a->dev) in aarp_rcv()
787 /* We can fill one in - this is good. */ in aarp_rcv()
788 ether_addr_copy(a->hwaddr, ea->hw_src); in aarp_rcv()
799 * If it is my address set ma to my address and reply. in aarp_rcv()
802 * as in a probe they are proposing an address not in aarp_rcv()
805 * Support for proxy-AARP added. We check if the in aarp_rcv()
806 * address is one of our proxies before we toss the in aarp_rcv()
810 sa.s_node = ea->pa_dst_node; in aarp_rcv()
811 sa.s_net = ea->pa_dst_net; in aarp_rcv()
816 ma = &ifa->address; in aarp_rcv()
817 else { /* We need to make a copy of the entry. */ in aarp_rcv()
826 * address. So as a precaution flush any in aarp_rcv()
827 * entries we have for this address. in aarp_rcv()
830 (AARP_HASH_SIZE - 1)], in aarp_rcv()
831 skb->dev, &sa); in aarp_rcv()
834 * Make it expire next tick - that avoids us in aarp_rcv()
840 a->expires_at = jiffies - 1; in aarp_rcv()
846 if (sa.s_node != ma->s_node) in aarp_rcv()
849 if (sa.s_net && ma->s_net && sa.s_net != ma->s_net) in aarp_rcv()
852 sa.s_node = ea->pa_src_node; in aarp_rcv()
853 sa.s_net = ea->pa_src_net; in aarp_rcv()
855 /* aarp_my_address has found the address to use for us. in aarp_rcv()
857 aarp_send_reply(dev, ma, &sa, ea->hw_src); in aarp_rcv()
883 return -ENOMEM; in aarp_proto_init()
914 * Get the aarp entry that is in the chain described
917 * pos = 1 is the first entry
921 int ct = iter->bucket; in iter_next()
922 struct aarp_entry **table = iter->table; in iter_next()
924 struct aarp_entry *entry; in iter_next() local
928 for (entry = table[ct]; entry; entry = entry->next) { in iter_next()
930 iter->table = table; in iter_next()
931 iter->bucket = ct; in iter_next()
932 return entry; in iter_next()
954 struct aarp_iter_state *iter = seq->private; in aarp_seq_start()
957 iter->table = resolved; in aarp_seq_start()
958 iter->bucket = 0; in aarp_seq_start()
965 struct aarp_entry *entry = v; in aarp_seq_next() local
966 struct aarp_iter_state *iter = seq->private; in aarp_seq_next()
972 entry = iter_next(iter, NULL); in aarp_seq_next()
974 /* next entry in current bucket */ in aarp_seq_next()
975 else if (entry->next) in aarp_seq_next()
976 entry = entry->next; in aarp_seq_next()
980 ++iter->bucket; in aarp_seq_next()
981 entry = iter_next(iter, NULL); in aarp_seq_next()
983 return entry; in aarp_seq_next()
1003 struct aarp_iter_state *iter = seq->private; in aarp_seq_show()
1004 struct aarp_entry *entry = v; in aarp_seq_show() local
1009 "Address Interface Hardware Address" in aarp_seq_show()
1012 seq_printf(seq, "%04X:%02X %-12s", in aarp_seq_show()
1013 ntohs(entry->target_addr.s_net), in aarp_seq_show()
1014 (unsigned int) entry->target_addr.s_node, in aarp_seq_show()
1015 entry->dev ? entry->dev->name : "????"); in aarp_seq_show()
1016 seq_printf(seq, "%pM", entry->hwaddr); in aarp_seq_show()
1018 dt2str((long)entry->expires_at - (long)now)); in aarp_seq_show()
1019 if (iter->table == unresolved) in aarp_seq_show()
1021 dt2str(now - entry->last_sent), in aarp_seq_show()
1022 entry->xmit_count); in aarp_seq_show()
1026 (iter->table == resolved) ? "resolved" in aarp_seq_show()
1027 : (iter->table == unresolved) ? "unresolved" in aarp_seq_show()
1028 : (iter->table == proxies) ? "proxies" in aarp_seq_show()