diff options
author | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2017-05-16 13:09:22 +0000 |
---|---|---|
committer | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2017-05-16 13:09:22 +0000 |
commit | 91af3722556bf90712145307ef4e2e3bf104104b (patch) | |
tree | ac7235ff6b674a97d7d79119fddf382416d03194 /sys/netinet | |
parent | 794be2e5cdde6cb4922ac4b60ab65794032a6496 (diff) |
Sync three changes that were caught by IPv6 multicast routing review:
* use a variable to allow disabling debugs on run-time
* fix a potential memory leak on copyout() failure
* don't just blindly use the first address provided by ifalist
ok bluhm@
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_mroute.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index ae9a0cbb994..0c32da6c4e4 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_mroute.c,v 1.117 2017/05/16 13:05:07 rzalamena Exp $ */ +/* $OpenBSD: ip_mroute.c,v 1.118 2017/05/16 13:09:21 rzalamena Exp $ */ /* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */ /* @@ -79,9 +79,12 @@ /* #define MCAST_DEBUG */ #ifdef MCAST_DEBUG +int mcast_debug = 1; #define DPRINTF(fmt, args...) \ do { \ - printf("%s:%d " fmt "\n", __func__, __LINE__, ## args); \ + if (mcast_debug) \ + printf("%s:%d " fmt "\n", \ + __func__, __LINE__, ## args); \ } while (0) #else #define DPRINTF(fmt, args...) \ @@ -471,8 +474,10 @@ mrt_sysctl_mfc(void *oldp, size_t *oldlenp) rtable_walk(rtableid, AF_INET, mrt_rtwalk_mfcsysctl, &msa); if (msa.msa_minfos != NULL && msa.msa_needed > 0 && - (error = copyout(msa.msa_minfos, oldp, msa.msa_needed)) != 0) + (error = copyout(msa.msa_minfos, oldp, msa.msa_needed)) != 0) { + free(msa.msa_minfos, M_TEMP, *oldlenp); return (error); + } free(msa.msa_minfos, M_TEMP, *oldlenp); *oldlenp = msa.msa_needed; @@ -1292,7 +1297,11 @@ rt_mcast_add(struct ifnet *ifp, struct sockaddr *origin, struct sockaddr *group) int rv; unsigned int rtableid = ifp->if_rdomain; - if ((ifa = TAILQ_FIRST(&ifp->if_addrlist)) == NULL) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + if (ifa->ifa_addr->sa_family == AF_INET) + break; + } + if (ifa == NULL) { DPRINTF("ifa == NULL"); return (NULL); } |