The IP multicast forward functions return an errno, call the variable
authorbluhm <bluhm@openbsd.org>
Mon, 19 Jun 2017 17:00:16 +0000 (17:00 +0000)
committerbluhm <bluhm@openbsd.org>
Mon, 19 Jun 2017 17:00:16 +0000 (17:00 +0000)
error.  Make the ip_mforward() return value consistent.  Simplify
the caller logic in ipv6_input() like in IPv4.
OK mpi@

sys/netinet/ip_input.c
sys/netinet/ip_mroute.c
sys/netinet6/ip6_input.c

index 9c8c9ba..c4bbed9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ip_input.c,v 1.310 2017/05/31 05:59:09 mpi Exp $      */
+/*     $OpenBSD: ip_input.c,v 1.311 2017/06/19 17:00:16 bluhm Exp $    */
 /*     $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $   */
 
 /*
@@ -377,7 +377,7 @@ ipv4_input(struct ifnet *ifp, struct mbuf *m)
 
 #ifdef MROUTING
                if (ipmforwarding && ip_mrouter[ifp->if_rdomain]) {
-                       int rv;
+                       int error;
 
                        if (m->m_flags & M_EXT) {
                                if ((m = m_pullup(m, hlen)) == NULL) {
@@ -399,9 +399,9 @@ ipv4_input(struct ifnet *ifp, struct mbuf *m)
                         * ip_output().)
                         */
                        KERNEL_LOCK();
-                       rv = ip_mforward(m, ifp);
+                       error = ip_mforward(m, ifp);
                        KERNEL_UNLOCK();
-                       if (rv != 0) {
+                       if (error) {
                                ipstat_inc(ips_cantforward);
                                goto bad;
                        }
index 0c32da6..1f4e6da 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ip_mroute.c,v 1.118 2017/05/16 13:09:21 rzalamena Exp $       */
+/*     $OpenBSD: ip_mroute.c,v 1.119 2017/06/19 17:00:16 bluhm Exp $   */
 /*     $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $      */
 
 /*
@@ -1084,8 +1084,7 @@ ip_mforward(struct mbuf *m, struct ifnet *ifp)
                if ((srctun++ % 1000) == 0)
                        log(LOG_ERR, "ip_mforward: received source-routed "
                            "packet from %x\n", ntohl(ip->ip_src.s_addr));
-
-               return (1);
+               return (EOPNOTSUPP);
        }
 
        /*
index 7018444..b763c59 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ip6_input.c,v 1.194 2017/05/31 05:59:09 mpi Exp $     */
+/*     $OpenBSD: ip6_input.c,v 1.195 2017/06/19 17:00:16 bluhm Exp $   */
 /*     $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $     */
 
 /*
@@ -381,6 +381,8 @@ ipv6_input(struct ifnet *ifp, struct mbuf *m)
 
 #ifdef MROUTING
                if (ip6_mforwarding && ip6_mrouter[ifp->if_rdomain]) {
+                       int error;
+
                        if (ip6_hbhchcheck(m, &off, &nxt, &ours))
                                goto out;
 
@@ -395,16 +397,20 @@ ipv6_input(struct ifnet *ifp, struct mbuf *m)
                         * must be discarded, else it may be accepted below.
                         */
                        KERNEL_LOCK();
-                       if (ip6_mforward(ip6, ifp, m)) {
+                       error = ip6_mforward(ip6, ifp, m);
+                       KERNEL_UNLOCK();
+                       if (error) {
                                ip6stat_inc(ip6s_cantforward);
-                               m_freem(m);
-                       } else if (ours) {
+                               goto bad;
+                       }
+
+                       if (ours) {
+                               KERNEL_LOCK();
                                ip6_deliver(&m, &off, nxt, AF_INET6);
-                       } else {
-                               m_freem(m);
+                               KERNEL_UNLOCK();
+                               goto out;
                        }
-                       KERNEL_UNLOCK();
-                       goto out;
+                       goto bad;
                }
 #endif
                if (!ours) {