Use refcount from "in_joingroup_locked()" when joining multicast

groups. Do not acquire additional references. This makes the IPv4 IGMP
code in line with the IPv6 MLD code.

Background:
The IPv4 multicast code puts an extra reference on the in_multi struct
when joining groups.  This becomes visible when using daemons like
igmpproxy from ports, that multicast entries do not disappear from the
output of ifmcstat(8) when multicast streams are disconnected.

This fixes a regression issue after r349762.

While at it factor the ip_mfilter_insert() and ip6_mfilter_insert() calls
to avoid repeated "is_new" check.

Differential Revision:	https://reviews.freebsd.org/D22595
Tested by:	Guido van Rooij <guido@gvr.org>
Reviewed by:	rgrimes (network)
MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2019-12-03 08:46:59 +00:00
parent 7b9934a1c6
commit 5b64b824b9
2 changed files with 6 additions and 6 deletions

View File

@ -2211,7 +2211,11 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
__func__);
goto out_inp_locked;
}
inm_acquire(imf->imf_inm);
/*
* NOTE: Refcount from in_joingroup_locked()
* is protecting membership.
*/
ip_mfilter_insert(&imo->imo_head, imf);
} else {
CTR1(KTR_IGMPV3, "%s: merge inm state", __func__);
IN_MULTI_LIST_LOCK();
@ -2235,8 +2239,6 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
goto out_inp_locked;
}
}
if (is_new)
ip_mfilter_insert(&imo->imo_head, imf);
imf_commit(imf);
imf = NULL;

View File

@ -2111,6 +2111,7 @@ in6p_join_group(struct inpcb *inp, struct sockopt *sopt)
* NOTE: Refcount from in6_joingroup_locked()
* is protecting membership.
*/
ip6_mfilter_insert(&imo->im6o_head, imf);
} else {
CTR1(KTR_MLD, "%s: merge inm state", __func__);
IN6_MULTI_LIST_LOCK();
@ -2136,9 +2137,6 @@ in6p_join_group(struct inpcb *inp, struct sockopt *sopt)
}
}
if (is_new)
ip6_mfilter_insert(&imo->im6o_head, imf);
im6f_commit(imf);
imf = NULL;