Source-Changes-HG archive

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

[src/trunk]: src/sys/net improve duplicated 'gifconfig" check (fatal typo was...



details:   https://anonhg.NetBSD.org/src/rev/9d1989e007f7
branches:  trunk
changeset: 486247:9d1989e007f7
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed May 17 01:14:04 2000 +0000

description:
improve duplicated 'gifconfig" check (fatal typo was there).  sync with kame.

diffstat:

 sys/net/if_gif.c |  41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)

diffs (73 lines):

diff -r 07c4d2a3cd2e -r 9d1989e007f7 sys/net/if_gif.c
--- a/sys/net/if_gif.c  Tue May 16 22:07:30 2000 +0000
+++ b/sys/net/if_gif.c  Wed May 17 01:14:04 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: if_gif.c,v 1.9 2000/04/19 06:30:52 itojun Exp $        */
-/*     $KAME: if_gif.c,v 1.21 2000/04/19 06:20:11 itojun Exp $ */
+/*     $NetBSD: if_gif.c,v 1.10 2000/05/17 01:14:04 itojun Exp $       */
+/*     $KAME: if_gif.c,v 1.26 2000/05/17 01:09:26 itojun Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -355,8 +355,7 @@
                return;
        }
 
-       if (m->m_pkthdr.rcvif)
-               m->m_pkthdr.rcvif = gifp;
+       m->m_pkthdr.rcvif = gifp;
        
 #if NBPFILTER > 0
        if (gifp->if_bpf) {
@@ -500,7 +499,6 @@
 #ifdef INET6
        case SIOCSIFPHYADDR_IN6:
 #endif /* INET6 */
-               /* can't configure same pair of address onto two gifs */
                src = (struct sockaddr *)
                        &(((struct in_aliasreq *)data)->ifra_addr);
                dst = (struct sockaddr *)
@@ -511,15 +509,38 @@
                                continue;
                        if (!sc2->gif_pdst || !sc2->gif_psrc)
                                continue;
-                       if (sc2->gif_pdst->sa_family == dst->sa_family &&
-                           sc2->gif_pdst->sa_len == dst->sa_family &&
-                           bcmp(sc2->gif_pdst, dst, dst->sa_len) == 0 &&
-                           sc2->gif_psrc->sa_family == src->sa_family &&
-                           sc2->gif_psrc->sa_len == src->sa_family &&
+                       if (sc2->gif_pdst->sa_family != dst->sa_family ||
+                           sc2->gif_pdst->sa_len != dst->sa_len ||
+                           sc2->gif_psrc->sa_family != src->sa_family ||
+                           sc2->gif_psrc->sa_len != src->sa_len)
+                               continue;
+
+                       /* can't configure same pair of address onto two gifs */
+                       if (bcmp(sc2->gif_pdst, dst, dst->sa_len) == 0 &&
                            bcmp(sc2->gif_psrc, src, src->sa_len) == 0) {
                                error = EADDRNOTAVAIL;
                                goto bad;
                        }
+
+                       /* can't configure multiple multi-dest interfaces */
+#define multidest(x) \
+       (((struct sockaddr_in *)(x))->sin_addr.s_addr == INADDR_ANY)
+#ifdef INET6
+#define multidest6(x) \
+       (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)(x))->sin6_addr))
+#endif
+                       if (dst->sa_family == AF_INET &&
+                           multidest(dst) && multidest(sc2->gif_pdst)) {
+                               error = EADDRNOTAVAIL;
+                               goto bad;
+                       }
+#ifdef INET6
+                       if (dst->sa_family == AF_INET6 &&
+                           multidest6(dst) && multidest6(sc2->gif_pdst)) {
+                               error = EADDRNOTAVAIL;
+                               goto bad;
+                       }
+#endif
                }
 
                if (src->sa_family != dst->sa_family ||



Home | Main Index | Thread Index | Old Index