ims_merge in in_mcast.c and in6_mcast.c

Dheeraj Kandula dkandula at gmail.com
Mon Oct 12 17:01:35 UTC 2020


974
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l974>
/*
975
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l975>
*
Merge socket-layer source into IGMP-layer source.
976
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l976>
*
If rollback is non-zero, perform the inverse of the merge.
977
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l977>
*/
978
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l978>
static
void
979
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l979>
ims_merge(struct
ip_msource *ims, const struct in_msource *lims,
980
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l980>
const
int rollback)
981
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l981>
{
982
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l982>
int
n = rollback ? -1 : 1;
983
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l983>
984
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l984>
if
(lims->imsl_st[0] == MCAST_EXCLUDE) {
985
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l985>
CTR3(KTR_IGMPV3,
"%s: t1 ex -= %d on 0x%08x",
986
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l986>
__func__,
n, ims->ims_haddr);
987
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l987>
ims->ims_st[1].ex
-= n;
988
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l988>
}
else if (lims->imsl_st[0] == MCAST_INCLUDE) {
989
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l989>
CTR3(KTR_IGMPV3,
"%s: t1 in -= %d on 0x%08x",
990
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l990>
__func__,
n, ims->ims_haddr);
991
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l991>
ims->ims_st[1].in
-= n;
992
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l992>
}
993
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l993>
994
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l994>
if
(lims->imsl_st[1] == MCAST_EXCLUDE) {
995
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l995>
CTR3(KTR_IGMPV3,
"%s: t1 ex += %d on 0x%08x",
996
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l996>
__func__,
n, ims->ims_haddr);
997
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l997>
ims->ims_st[1].ex
+= n;
998
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l998>
}
else if (lims->imsl_st[1] == MCAST_INCLUDE) {
999
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l999>
CTR3(KTR_IGMPV3,
"%s: t1 in += %d on 0x%08x",
1000
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l1000>
__func__,
n, ims->ims_haddr);
1001
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l1001>
ims->ims_st[1].in
+= n;
1002
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l1002>
}
1003
<https://svnweb.freebsd.org/base/head/sys/netinet/in_mcast.c?revision=365071&view=markup#l1003>
}


On line 987 and 991 shouldn't the index be 0 instead of 1.

i.e. ims->ims_st[0].ex -= n;
and
ims->ims_st[0].in -= n;

On a rollback, the entry at index 0 is incremented and the entry at index 1
is decremented.

On a non-rollback merge, the entry at index 0 is decremented and the entry
at index 1 is incremented.

Dheeraj


More information about the freebsd-net mailing list