Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys integrate IEEE1394 ARP into generic ARP logic.



details:   https://anonhg.NetBSD.org/src/rev/c79a9fbd679c
branches:  trunk
changeset: 533200:c79a9fbd679c
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Jun 24 08:06:20 2002 +0000

description:
integrate IEEE1394 ARP into generic ARP logic.
XXX there's no check at all in ar_hrd, and we don't set ar_hrd on outgoing.
it seems like a bad thing.

diffstat:

 sys/conf/files               |    3 +-
 sys/net/if_arp.h             |   13 +-
 sys/net/if_ieee1394subr.c    |   17 +-
 sys/netinet/if_arp.c         |   78 ++++-
 sys/netinet/if_ieee1394arp.c |  672 -------------------------------------------
 sys/netinet/if_ieee1394arp.h |   55 ---
 6 files changed, 81 insertions(+), 757 deletions(-)

diffs (truncated from 1025 to 300 lines):

diff -r 6ffc069ff59a -r c79a9fbd679c sys/conf/files
--- a/sys/conf/files    Mon Jun 24 08:01:35 2002 +0000
+++ b/sys/conf/files    Mon Jun 24 08:06:20 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.535 2002/06/18 00:33:57 thorpej Exp $
+#      $NetBSD: files,v 1.536 2002/06/24 08:06:20 itojun Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -1156,7 +1156,6 @@
 file   netccitt/pk_usrreq.c            ccitt
 file   netinet/fil.c                   ipfilter
 file   netinet/if_arp.c                arp | netatalk          needs-flag
-file   netinet/if_ieee1394arp.c        arp & ieee1394 & inet
 file   netinet/if_atm.c                atm
 file   netinet/igmp.c                  inet
 file   netinet/in.c                    inet
diff -r 6ffc069ff59a -r c79a9fbd679c sys/net/if_arp.h
--- a/sys/net/if_arp.h  Mon Jun 24 08:01:35 2002 +0000
+++ b/sys/net/if_arp.h  Mon Jun 24 08:06:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.h,v 1.22 2001/06/12 15:17:27 wiz Exp $  */
+/*     $NetBSD: if_arp.h,v 1.23 2002/06/24 08:06:22 itojun Exp $       */
 
 /*
  * Copyright (c) 1986, 1993
@@ -76,9 +76,14 @@
        u_int8_t  ar_tpa[];     /* target protocol address */
 #endif
 #define ar_sha(ap) (((caddr_t)((ap)+1))+0)
-#define ar_spa(ap) (((caddr_t)((ap)+1))+  (ap)->ar_hln)
-#define ar_tha(ap) (((caddr_t)((ap)+1))+  (ap)->ar_hln+(ap)->ar_pln)
-#define ar_tpa(ap) (((caddr_t)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
+#define ar_spa(ap) (((caddr_t)((ap)+1))+(ap)->ar_hln)
+#define ar_tha(ap) \
+       (ntohs((ap)->ar_hrd) == ARPHRD_IEEE1394 \
+               ? NULL : (((caddr_t)((ap)+1))+(ap)->ar_hln+(ap)->ar_pln))
+#define ar_tpa(ap) \
+       (ntohs((ap)->ar_hrd) == ARPHRD_IEEE1394 \
+               ? (((caddr_t)((ap)+1))+(ap)->ar_hln+(ap)->ar_pln) \
+               : (((caddr_t)((ap)+1))+(ap)->ar_hln+(ap)->ar_pln+(ap)->ar_hln))
 } __attribute__((__packed__));
 
 
diff -r 6ffc069ff59a -r c79a9fbd679c sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Mon Jun 24 08:01:35 2002 +0000
+++ b/sys/net/if_ieee1394subr.c Mon Jun 24 08:06:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee1394subr.c,v 1.15 2002/05/16 09:08:33 haya Exp $        */
+/*     $NetBSD: if_ieee1394subr.c,v 1.16 2002/06/24 08:06:22 itojun Exp $      */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.15 2002/05/16 09:08:33 haya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.16 2002/06/24 08:06:22 itojun Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -66,7 +66,7 @@
 #ifdef INET
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet/if_ieee1394arp.h>
+#include <netinet/if_inarp.h>
 #endif /* INET */
 #ifdef INET6
 #include <netinet/in.h>
@@ -93,9 +93,6 @@
        struct rtentry *rt;
        struct mbuf *mcopy = NULL;
        struct ieee1394_hwaddr hwdst, *myaddr;
-#ifdef INET
-       struct ieee1394_arphdr *ah;
-#endif /* INET */
        ALTQ_DECL(struct altq_pktattr pktattr;)
 
        if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
@@ -146,7 +143,7 @@
        case AF_INET:
                if (m0->m_flags & (M_BCAST | M_MCAST))
                        memcpy(&hwdst, ifp->if_broadcastaddr, sizeof(hwdst));
-               else if (!ieee1394arpresolve(ifp, rt, m0, dst, &hwdst))
+               else if (!arpresolve(ifp, rt, m0, dst, (u_char *)&hwdst))
                        return 0;       /* if not yet resolved */
                /* if broadcasting on a simplex interface, loopback a copy */
                if ((m0->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
@@ -154,7 +151,6 @@
                etype = htons(ETHERTYPE_IP);
                break;
        case AF_ARP:
-               ah = mtod(m0, struct ieee1394_arphdr *);
                memcpy(&hwdst, ifp->if_broadcastaddr, sizeof(hwdst));
                etype = htons(ETHERTYPE_ARP);
                break;
@@ -388,7 +384,8 @@
                break;
 
        case ETHERTYPE_ARP:
-               in_ieee1394arpinput(m);
+               schednetisr(NETISR_ARP);
+               inq = &arpintrq;
                return;
 #endif /* INET */
 
@@ -703,7 +700,7 @@
                        if ((error = fw_init(ifp)) != 0)
 #endif
                                break;
-                       ieee1394arp_ifinit(ifp, ifa);
+                       arp_ifinit(ifp, ifa);
                        break;
 #endif /* INET */
                default:
diff -r 6ffc069ff59a -r c79a9fbd679c sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Mon Jun 24 08:01:35 2002 +0000
+++ b/sys/netinet/if_arp.c      Mon Jun 24 08:06:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.81 2002/06/09 16:33:37 itojun Exp $       */
+/*     $NetBSD: if_arp.c,v 1.82 2002/06/24 08:06:22 itojun Exp $       */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.81 2002/06/09 16:33:37 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.82 2002/06/24 08:06:22 itojun Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -110,7 +110,6 @@
 #include <net/if_types.h>
 #include <net/route.h>
 
-
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/in_var.h>
@@ -248,8 +247,7 @@
  * while the arp table is locked, we punt and try again later.
  */
 
-int    arp_locked;
-
+static int     arp_locked;
 static __inline int arp_lock_try __P((int));
 static __inline void arp_unlock __P((void));
 
@@ -619,12 +617,28 @@
 
        if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL)
                return;
-       m->m_len = sizeof(*ah) + 2*sizeof(struct in_addr) +
-           2*ifp->if_data.ifi_addrlen;
+       switch (ifp->if_type) {
+       case IFT_IEEE1394:
+               m->m_len = sizeof(*ah) + 2 * sizeof(struct in_addr) +
+                   ifp->if_data.ifi_addrlen;
+               break;
+       default:
+               m->m_len = sizeof(*ah) + 2 * sizeof(struct in_addr) +
+                   2 * ifp->if_data.ifi_addrlen;
+               break;
+       }
        m->m_pkthdr.len = m->m_len;
        MH_ALIGN(m, m->m_len);
        ah = mtod(m, struct arphdr *);
        bzero((caddr_t)ah, m->m_len);
+       switch (ifp->if_type) {
+       case IFT_IEEE1394:
+               ah->ar_hrd = htons(ARPHRD_IEEE1394);
+               break;
+       default:
+               /* why we don't set ar_hrd in other cases? */
+               break;
+       }
        ah->ar_pro = htons(ETHERTYPE_IP);
        ah->ar_hln = ifp->if_data.ifi_addrlen;  /* hardware address length */
        ah->ar_pln = sizeof(struct in_addr);    /* protocol address length */
@@ -745,6 +759,7 @@
        struct mbuf *m;
        struct arphdr *ar;
        int s;
+       int arplen;
 
        while (arpintrq.ifq_head) {
                s = splnet();
@@ -755,13 +770,22 @@
 
                arpstat.as_rcvtotal++;
 
+               switch (m->m_pkthdr.rcvif->if_type) {
+               case IFT_IEEE1394:
+                       arplen = sizeof(struct arphdr) +
+                           ar->ar_hln + 2 * ar->ar_pln;
+                       break;
+               default:
+                       arplen = sizeof(struct arphdr) +
+                           2 * ar->ar_hln + 2 * ar->ar_pln;
+                       break;
+               }
+
                if (m->m_len >= sizeof(struct arphdr) &&
                    (ar = mtod(m, struct arphdr *)) &&
                    /* XXX ntohs(ar->ar_hrd) == ARPHRD_ETHER && */
-                   m->m_len >=
-                     sizeof(struct arphdr) + 2 * (ar->ar_hln + ar->ar_pln))
+                   m->m_len >= arplen)
                        switch (ntohs(ar->ar_pro)) {
-
                        case ETHERTYPE_IP:
                        case ETHERTYPE_IPTRAILERS:
                                in_arpinput(m);
@@ -813,6 +837,21 @@
        bcopy((caddr_t)ar_spa(ah), (caddr_t)&isaddr, sizeof (isaddr));
        bcopy((caddr_t)ar_tpa(ah), (caddr_t)&itaddr, sizeof (itaddr));
 
+       switch (m->m_pkthdr.rcvif->if_type) {
+       case IFT_IEEE1394:
+               if (ntohs(ah->ar_hrd) == ARPHRD_IEEE1394)
+                       ;
+               else {
+                       /* XXX this is to make sure we compute ar_tha right */
+                       /* XXX check ar_hrd more strictly? */
+                       ah->ar_hrd = htons(ARPHRD_IEEE1394);
+               }
+               break;
+       default:
+               /* XXX check ar_hrd? */
+               break;
+       }
+
        if (m->m_flags & (M_BCAST|M_MCAST))
                arpstat.as_rcvmcast++;
 
@@ -1014,14 +1053,18 @@
        arpstat.as_rcvrequest++;
        if (in_hosteq(itaddr, myaddr)) {
                /* I am the target */
-               bcopy((caddr_t)ar_sha(ah), (caddr_t)ar_tha(ah), ah->ar_hln);
+               if (ar_tha(ah))
+                       bcopy((caddr_t)ar_sha(ah), (caddr_t)ar_tha(ah),
+                           ah->ar_hln);
                bcopy(LLADDR(ifp->if_sadl), (caddr_t)ar_sha(ah), ah->ar_hln);
        } else {
                la = arplookup(m, &itaddr, 0, SIN_PROXY);
                if (la == 0)
                        goto out;
                rt = la->la_rt;
-               bcopy((caddr_t)ar_sha(ah), (caddr_t)ar_tha(ah), ah->ar_hln);
+               if (ar_tha(ah))
+                       bcopy((caddr_t)ar_sha(ah), (caddr_t)ar_tha(ah),
+                           ah->ar_hln);
                sdl = SDL(rt->rt_gateway);
                bcopy(LLADDR(sdl), (caddr_t)ar_sha(ah), ah->ar_hln);
        }
@@ -1159,7 +1202,6 @@
        if (m->m_len < sizeof(struct arphdr) + 2 * (ar->ar_hln + ar->ar_pln))
                goto out;
        switch (ntohs(ar->ar_pro)) {
-
        case ETHERTYPE_IP:
        case ETHERTYPE_IPTRAILERS:
                in_revarpinput(m);
@@ -1193,6 +1235,15 @@
 
        ah = mtod(m, struct arphdr *);
        op = ntohs(ah->ar_op);
+
+       switch (m->m_pkthdr.rcvif->if_type) {
+       case IFT_IEEE1394:
+               /* ARP without target hardware address is not supported */
+               goto out;
+       default:
+               break;
+       }
+
        switch (op) {
        case ARPOP_REQUEST:
        case ARPOP_REPLY:       /* per RFC */
@@ -1410,4 +1461,3 @@
 }
 #endif
 #endif /* INET */
-
diff -r 6ffc069ff59a -r c79a9fbd679c sys/netinet/if_ieee1394arp.c
--- a/sys/netinet/if_ieee1394arp.c      Mon Jun 24 08:01:35 2002 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,672 +0,0 @@
-/*     $NetBSD: if_ieee1394arp.c,v 1.8 2002/06/09 16:33:37 itojun Exp $        */
-
-/*
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *



Home | Main Index | Thread Index | Old Index