From: bluhm Date: Mon, 19 Jun 2017 17:00:16 +0000 (+0000) Subject: The IP multicast forward functions return an errno, call the variable X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7a3dea7e8ef7831bf445b52ab2c5981784d9068e;p=openbsd The IP multicast forward functions return an errno, call the variable error. Make the ip_mforward() return value consistent. Simplify the caller logic in ipv6_input() like in IPv4. OK mpi@ --- diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 9c8c9ba0280..c4bbed9d015 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -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; } diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 0c32da6c4e4..1f4e6da4478 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -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); } /* diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 7018444ba98..b763c59e562 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -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) {