Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netatalk Fix AppleTalk name registration, as discussed o...
details: https://anonhg.NetBSD.org/src/rev/5be85dab2267
branches: trunk
changeset: 773338:5be85dab2267
user: hauke <hauke%NetBSD.org@localhost>
date: Tue Jan 31 09:53:44 2012 +0000
description:
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.
Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.
Needs to be pulled up to netbsd-5.
diffstat:
sys/netatalk/aarp.c | 20 ++++++++++++++------
sys/netatalk/ddp_output.c | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 49 insertions(+), 12 deletions(-)
diffs (128 lines):
diff -r 5f93fc54a6e6 -r 5be85dab2267 sys/netatalk/aarp.c
--- a/sys/netatalk/aarp.c Tue Jan 31 09:41:37 2012 +0000
+++ b/sys/netatalk/aarp.c Tue Jan 31 09:53:44 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aarp.c,v 1.35 2011/05/08 13:51:31 bouyer Exp $ */
+/* $NetBSD: aarp.c,v 1.36 2012/01/31 09:53:44 hauke Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aarp.c,v 1.35 2011/05/08 13:51:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aarp.c,v 1.36 2012/01/31 09:53:44 hauke Exp $");
#include "opt_mbuftrace.h"
@@ -222,11 +222,19 @@
ea->aarp_tpa = sat->sat_addr.s_node;
}
+ /* If we are talking to ourselves, use the loopback interface. */
+ if (AA_SAT(aa)->sat_addr.s_net == sat->sat_addr.s_net &&
+ AA_SAT(aa)->sat_addr.s_node == sat->sat_addr.s_node)
+ ifp = lo0ifp;
+
#ifdef NETATALKDEBUG
- printf("aarp: sending request via %u.%u seaking %u.%u\n",
- ntohs(AA_SAT(aa)->sat_addr.s_net), AA_SAT(aa)->sat_addr.s_node,
- ntohs(sat->sat_addr.s_net), sat->sat_addr.s_node);
-#endif /* NETATALKDEBUG */
+ printf("aarp: sending request via %u.%u through %s seeking %u.%u\n",
+ ntohs(AA_SAT(aa)->sat_addr.s_net),
+ AA_SAT(aa)->sat_addr.s_node,
+ ifp->if_xname,
+ ntohs(sat->sat_addr.s_net),
+ sat->sat_addr.s_node);
+#endif /* NETATALKDEBUG */
sa.sa_len = sizeof(struct sockaddr);
sa.sa_family = AF_UNSPEC;
diff -r 5f93fc54a6e6 -r 5be85dab2267 sys/netatalk/ddp_output.c
--- a/sys/netatalk/ddp_output.c Tue Jan 31 09:41:37 2012 +0000
+++ b/sys/netatalk/ddp_output.c Tue Jan 31 09:53:44 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ddp_output.c,v 1.15 2011/07/17 20:54:53 joerg Exp $ */
+/* $NetBSD: ddp_output.c,v 1.16 2012/01/31 09:53:44 hauke Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddp_output.c,v 1.15 2011/07/17 20:54:53 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddp_output.c,v 1.16 2012/01/31 09:53:44 hauke Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -126,20 +126,40 @@
struct elaphdr *elh;
struct at_ifaddr *aa = NULL;
struct ifnet *ifp = NULL;
- u_short net;
+ uint16_t net;
+ uint8_t node;
+ uint8_t loopback = 0;
if ((rt = rtcache_validate(ro)) != NULL && (ifp = rt->rt_ifp) != NULL) {
+ const struct sockaddr_at *dst = satocsat(rtcache_getdst(ro));
+ uint16_t dnet = dst->sat_addr.s_net;
+ uint8_t dnode = dst->sat_addr.s_node;
net = satosat(rt->rt_gateway)->sat_addr.s_net;
+ node = satosat(rt->rt_gateway)->sat_addr.s_node;
+
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
- if (aa->aa_ifp == ifp &&
- ntohs(net) >= ntohs(aa->aa_firstnet) &&
+ if (ntohs(net) >= ntohs(aa->aa_firstnet) &&
ntohs(net) <= ntohs(aa->aa_lastnet)) {
+ /* Are we talking to ourselves? */
+ if (dnet == aa->aa_addr.sat_addr.s_net &&
+ dnode == aa->aa_addr.sat_addr.s_node) {
+ /* If to us, redirect to lo0. */
+ ifp = lo0ifp;
+ }
+ /* Or is it a broadcast? */
+ else if (dnet == aa->aa_addr.sat_addr.s_net &&
+ dnode == 255) {
+ /* If broadcast, loop back a copy. */
+ loopback = 1;
+ }
break;
}
}
}
if (aa == NULL) {
+#ifdef NETATALKDEBUG
printf("%s: no address found\n", __func__);
+#endif
m_freem(m);
return EINVAL;
}
@@ -161,7 +181,8 @@
ntohs(aa->aa_firstnet) &&
ntohs(satocsat(rtcache_getdst(ro))->sat_addr.s_net) <=
ntohs(aa->aa_lastnet)) {
- elh->el_dnode = satocsat(rtcache_getdst(ro))->sat_addr.s_node;
+ elh->el_dnode =
+ satocsat(rtcache_getdst(ro))->sat_addr.s_node;
} else {
elh->el_dnode =
satosat(rt->rt_gateway)->sat_addr.s_node;
@@ -182,5 +203,13 @@
#endif
/* XXX */
+ if (loopback && rtcache_getdst(ro)->sa_family == AF_APPLETALK) {
+ struct mbuf *copym = m_copypacket(m, M_DONTWAIT);
+
+#ifdef NETATALKDEBUG
+ printf("Looping back (not AARP).\n");
+#endif
+ looutput(lo0ifp, copym, rtcache_getdst(ro), NULL);
+ }
return (*ifp->if_output)(ifp, m, (struct sockaddr *)&gate, NULL);
}
Home |
Main Index |
Thread Index |
Old Index