Deleted Added
full compact
in_mcast.c (197135) in_mcast.c (197136)
1/*-
2 * Copyright (c) 2007-2009 Bruce Simpson.
3 * Copyright (c) 2005 Robert N. M. Watson.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 19 unchanged lines hidden (view full) ---

28 * SUCH DAMAGE.
29 */
30
31/*
32 * IPv4 multicast socket, group, and socket option processing module.
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007-2009 Bruce Simpson.
3 * Copyright (c) 2005 Robert N. M. Watson.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 19 unchanged lines hidden (view full) ---

28 * SUCH DAMAGE.
29 */
30
31/*
32 * IPv4 multicast socket, group, and socket option processing module.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/netinet/in_mcast.c 197135 2009-09-12 20:18:23Z bms $");
36__FBSDID("$FreeBSD: head/sys/netinet/in_mcast.c 197136 2009-09-12 20:37:44Z bms $");
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/malloc.h>
42#include <sys/mbuf.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>

--- 1807 unchanged lines hidden (view full) ---

1852 struct ip_moptions *imo;
1853 struct in_multi *inm;
1854 struct in_msource *lims;
1855 size_t idx;
1856 int error, is_new;
1857
1858 ifp = NULL;
1859 imf = NULL;
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/malloc.h>
42#include <sys/mbuf.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>

--- 1807 unchanged lines hidden (view full) ---

1852 struct ip_moptions *imo;
1853 struct in_multi *inm;
1854 struct in_msource *lims;
1855 size_t idx;
1856 int error, is_new;
1857
1858 ifp = NULL;
1859 imf = NULL;
1860 lims = NULL;
1860 error = 0;
1861 is_new = 0;
1862
1863 memset(&gsr, 0, sizeof(struct group_source_req));
1864 gsa = (sockunion_t *)&gsr.gsr_group;
1865 gsa->ss.ss_family = AF_UNSPEC;
1866 ssa = (sockunion_t *)&gsr.gsr_source;
1867 ssa->ss.ss_family = AF_UNSPEC;

--- 101 unchanged lines hidden (view full) ---

1969 * MCAST_JOIN_SOURCE on an exclusive membership
1970 * is an error. On an existing inclusive membership,
1971 * it just adds the source to the filter list.
1972 */
1973 if (imf->imf_st[1] != MCAST_INCLUDE) {
1974 error = EINVAL;
1975 goto out_inp_locked;
1976 }
1861 error = 0;
1862 is_new = 0;
1863
1864 memset(&gsr, 0, sizeof(struct group_source_req));
1865 gsa = (sockunion_t *)&gsr.gsr_group;
1866 gsa->ss.ss_family = AF_UNSPEC;
1867 ssa = (sockunion_t *)&gsr.gsr_source;
1868 ssa->ss.ss_family = AF_UNSPEC;

--- 101 unchanged lines hidden (view full) ---

1970 * MCAST_JOIN_SOURCE on an exclusive membership
1971 * is an error. On an existing inclusive membership,
1972 * it just adds the source to the filter list.
1973 */
1974 if (imf->imf_st[1] != MCAST_INCLUDE) {
1975 error = EINVAL;
1976 goto out_inp_locked;
1977 }
1977 /* Throw out duplicates. */
1978 /*
1979 * Throw out duplicates.
1980 *
1981 * XXX FIXME: This makes a naive assumption that
1982 * even if entries exist for *ssa in this imf,
1983 * they will be rejected as dupes, even if they
1984 * are not valid in the current mode (in-mode).
1985 *
1986 * in_msource is transactioned just as for anything
1987 * else in SSM -- but note naive use of inm_graft()
1988 * below for allocating new filter entries.
1989 *
1990 * This is only an issue if someone mixes the
1991 * full-state SSM API with the delta-based API,
1992 * which is discouraged in the relevant RFCs.
1993 */
1978 lims = imo_match_source(imo, idx, &ssa->sa);
1994 lims = imo_match_source(imo, idx, &ssa->sa);
1979 if (lims != NULL) {
1995 if (lims != NULL /*&&
1996 lims->imsl_st[1] == MCAST_INCLUDE*/) {
1980 error = EADDRNOTAVAIL;
1981 goto out_inp_locked;
1982 }
1983 } else {
1984 /*
1985 * MCAST_JOIN_GROUP alone, on any existing membership,
1986 * is rejected, to stop the same inpcb tying up
1987 * multiple refs to the in_multi.

--- 38 unchanged lines hidden (view full) ---

2026 /*
2027 * Graft new source into filter list for this inpcb's
2028 * membership of the group. The in_multi may not have
2029 * been allocated yet if this is a new membership, however,
2030 * the in_mfilter slot will be allocated and must be initialized.
2031 *
2032 * Note: Grafting of exclusive mode filters doesn't happen
2033 * in this path.
1997 error = EADDRNOTAVAIL;
1998 goto out_inp_locked;
1999 }
2000 } else {
2001 /*
2002 * MCAST_JOIN_GROUP alone, on any existing membership,
2003 * is rejected, to stop the same inpcb tying up
2004 * multiple refs to the in_multi.

--- 38 unchanged lines hidden (view full) ---

2043 /*
2044 * Graft new source into filter list for this inpcb's
2045 * membership of the group. The in_multi may not have
2046 * been allocated yet if this is a new membership, however,
2047 * the in_mfilter slot will be allocated and must be initialized.
2048 *
2049 * Note: Grafting of exclusive mode filters doesn't happen
2050 * in this path.
2051 * XXX: Should check for non-NULL lims (node exists but may
2052 * not be in-mode) for interop with full-state API.
2034 */
2035 if (ssa->ss.ss_family != AF_UNSPEC) {
2036 /* Membership starts in IN mode */
2037 if (is_new) {
2038 CTR1(KTR_IGMPV3, "%s: new join w/source", __func__);
2039 imf_init(imf, MCAST_UNDEFINED, MCAST_INCLUDE);
2040 } else {
2041 CTR2(KTR_IGMPV3, "%s: %s source", __func__, "allow");

--- 847 unchanged lines hidden ---
2053 */
2054 if (ssa->ss.ss_family != AF_UNSPEC) {
2055 /* Membership starts in IN mode */
2056 if (is_new) {
2057 CTR1(KTR_IGMPV3, "%s: new join w/source", __func__);
2058 imf_init(imf, MCAST_UNDEFINED, MCAST_INCLUDE);
2059 } else {
2060 CTR2(KTR_IGMPV3, "%s: %s source", __func__, "allow");

--- 847 unchanged lines hidden ---