Date: Tue, 26 Aug 1997 17:22:21 -0700 From: Julian Elischer <julian@whistle.com> To: hackers@freebsd.org Cc: julian@alpo.whistle.com Subject: review please Netowrking change. patch.. Message-ID: <3403733D.13728473@whistle.com>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------2C67412E284797A9500F9F30 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Here is the patch for the appletalk fix I'd like to commit. --------------2C67412E284797A9500F9F30 Content-Type: text/plain; charset=us-ascii; name="diffs.3.0" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs.3.0" Index: net/if.c =================================================================== RCS file: /home/ncvs/src/sys/net/if.c,v retrieving revision 1.50 diff -c -r1.50 if.c *** if.c 1997/08/22 22:47:27 1.50 --- if.c 1997/08/26 23:37:28 *************** *** 270,275 **** --- 270,287 ---- return (ifa); } else { /* + * if we have a special address handler, + * then use it instead of the generic one. + */ + if (ifa->ifa_claim_addr) { + if ((*ifa->ifa_claim_addr)(ifa, addr)) { + return (ifa); + } else { + continue; + } + } + + /* * Scan all the bits in the ifa's address. * If a bit dissagrees with what we are * looking for, mask it with the netmask *************** *** 576,582 **** case SIOCSIFPHYS: error = suser(p->p_ucred, &p->p_acflag); if (error) ! return error; if (!ifp->if_ioctl) return EOPNOTSUPP; error = (*ifp->if_ioctl)(ifp, cmd, data); --- 588,594 ---- case SIOCSIFPHYS: error = suser(p->p_ucred, &p->p_acflag); if (error) ! return error; if (!ifp->if_ioctl) return EOPNOTSUPP; error = (*ifp->if_ioctl)(ifp, cmd, data); Index: net/if_var.h =================================================================== RCS file: /home/ncvs/src/sys/net/if_var.h,v retrieving revision 1.5 diff -c -r1.5 if_var.h *** if_var.h 1997/02/22 09:41:10 1.5 --- if_var.h 1997/08/26 23:37:29 *************** *** 254,259 **** --- 254,262 ---- #ifdef notdef struct rtentry *ifa_rt; /* XXXX for ROUTETOIF ????? */ #endif + int (*ifa_claim_addr) /* check if an addr goes to this if */ + __P((struct ifaddr *, struct sockaddr *)); + }; #define IFA_ROUTE RTF_UP /* route installed */ Index: netatalk/at_control.c =================================================================== RCS file: /home/ncvs/src/sys/netatalk/at_control.c,v retrieving revision 1.15 diff -c -r1.15 at_control.c *** at_control.c 1997/05/13 21:01:44 1.15 --- at_control.c 1997/08/26 23:37:30 *************** *** 36,41 **** --- 36,42 ---- static int at_scrub( struct ifnet *ifp, struct at_ifaddr *aa ); static int at_ifinit( struct ifnet *ifp, struct at_ifaddr *aa, struct sockaddr_at *sat ); + static int aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw); # define sateqaddr(a,b) ((a)->sat_len == (b)->sat_len && \ (a)->sat_family == (b)->sat_family && \ *************** *** 137,143 **** /* * If we failed to find an existing at_ifaddr entry, then we * allocate a fresh one. - * XXX change this to use malloc */ if ( aa == (struct at_ifaddr *) 0 ) { aa0 = malloc(sizeof(struct at_ifaddr), M_IFADDR, M_WAITOK); --- 138,143 ---- *************** *** 492,497 **** --- 492,503 ---- } /* + * Copy the phase. + */ + AA_SAT( aa )->sat_range.r_netrange.nr_phase + = ((aa->aa_flags & AFA_PHASE2) ? 2:1); + + /* * step through the nets in the range * starting at the (possibly random) start point. */ *************** *** 634,639 **** --- 640,650 ---- /* + * set the address of our "check if this addr is ours" routine. + */ + aa->aa_ifa.ifa_claim_addr = aa_claim_addr; + + /* * of course if we can't add these routes we back out, but it's getting * risky by now XXX */ *************** *** 834,836 **** --- 845,878 ---- #endif + static int + aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw0) + { + struct sockaddr_at *addr = (struct sockaddr_at *)ifa->ifa_addr; + struct sockaddr_at *gw = (struct sockaddr_at *)gw0; + + switch (gw->sat_range.r_netrange.nr_phase) { + case 1: + if(addr->sat_range.r_netrange.nr_phase == 1) + return 1; + case 0: + case 2: + /* + * if it's our net (including 0), + * or netranges are valid, and we are in the range, + * then it's ours. + */ + if ((addr->sat_addr.s_net == gw->sat_addr.s_net) + || ((addr->sat_range.r_netrange.nr_lastnet) + && (gw->sat_addr.s_net + >= addr->sat_range.r_netrange.nr_firstnet ) + && (gw->sat_addr.s_net + <= addr->sat_range.r_netrange.nr_lastnet ))) { + return 1; + } + break; + default: + printf("atalk: bad phase\n"); + } + return 0; + } Index: netatalk/ddp_output.c =================================================================== RCS file: /home/ncvs/src/sys/netatalk/ddp_output.c,v retrieving revision 1.4 diff -c -r1.4 ddp_output.c *** ddp_output.c 1997/03/05 09:17:37 1.4 --- ddp_output.c 1997/08/26 23:37:30 *************** *** 119,134 **** struct ifnet *ifp = NULL; u_short net; ! if ( ro->ro_rt && ( ifp = ro->ro_rt->rt_ifp )) { ! net = satosat( ro->ro_rt->rt_gateway )->sat_addr.s_net; for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { ! if ( aa->aa_ifp == ifp && ntohs( net ) >= ntohs( aa->aa_firstnet ) && ntohs( net ) <= ntohs( aa->aa_lastnet )) { break; } } } if ( aa == NULL ) { printf( "ddp_route: oops\n" ); m_freem( m ); --- 119,150 ---- struct ifnet *ifp = NULL; u_short net; ! /* ! * if we have a route, find the ifa that refers to this route. ! * I.e The ifa used to get to the gateway. ! */ ! if ( (ro->ro_rt == NULL) ! || ( ro->ro_rt->rt_ifa == NULL ) ! || ( (ifp = ro->ro_rt->rt_ifa->ifa_ifp) == NULL )) { ! rtalloc(ro); ! } ! if ( (ro->ro_rt != NULL) ! && ( ro->ro_rt->rt_ifa ) ! && ( ifp = ro->ro_rt->rt_ifa->ifa_ifp )) { ! net = satosat(ro->ro_rt->rt_gateway)->sat_addr.s_net; for ( aa = at_ifaddr; aa; aa = aa->aa_next ) { ! if (((net == 0) || (aa->aa_ifp == ifp)) && ntohs( net ) >= ntohs( aa->aa_firstnet ) && ntohs( net ) <= ntohs( aa->aa_lastnet )) { break; } } + } else { + printf( "ddp_route: still have no valid route\n"); + m_freem( m ); + return( EINVAL ); } + if ( aa == NULL ) { printf( "ddp_route: oops\n" ); m_freem( m ); --------------2C67412E284797A9500F9F30--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3403733D.13728473>