Commit 65411adb authored by David S. Miller's avatar David S. Miller

Merge branch 'igmp-ns'

Nikolay Borisov says:

====================
Make igmp sysctl knobs namespace aware

This series continue making more of the net related sysctls
namespace aware. The first 2 and last patches are straight
forward and convert sysctls which weren't defined to be
namespace aware. The only thing in them is that each removes
a define which is used in only one place (to initialise
the respective sysctl) so I don't think this is a huge loss.

The third patch however, converts igmp_llm_reports which was
already defined in the ipv4_net_table but wasn't using any of
the net namespace infrastructure.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1e2a8868 165094af
...@@ -37,11 +37,6 @@ static inline struct igmpv3_query * ...@@ -37,11 +37,6 @@ static inline struct igmpv3_query *
return (struct igmpv3_query *)skb_transport_header(skb); return (struct igmpv3_query *)skb_transport_header(skb);
} }
extern int sysctl_igmp_llm_reports;
extern int sysctl_igmp_max_memberships;
extern int sysctl_igmp_max_msf;
extern int sysctl_igmp_qrv;
struct ip_sf_socklist { struct ip_sf_socklist {
unsigned int sl_max; unsigned int sl_max;
unsigned int sl_count; unsigned int sl_count;
......
...@@ -108,6 +108,11 @@ struct netns_ipv4 { ...@@ -108,6 +108,11 @@ struct netns_ipv4 {
int sysctl_tcp_fin_timeout; int sysctl_tcp_fin_timeout;
unsigned int sysctl_tcp_notsent_lowat; unsigned int sysctl_tcp_notsent_lowat;
int sysctl_igmp_max_memberships;
int sysctl_igmp_max_msf;
int sysctl_igmp_llm_reports;
int sysctl_igmp_qrv;
struct ping_group_range ping_group_range; struct ping_group_range ping_group_range;
atomic_t dev_addr_genid; atomic_t dev_addr_genid;
......
...@@ -107,12 +107,6 @@ ...@@ -107,12 +107,6 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#endif #endif
#define IP_MAX_MEMBERSHIPS 20
#define IP_MAX_MSF 10
/* IGMP reports for link-local multicast groups are enabled by default */
int sysctl_igmp_llm_reports __read_mostly = 1;
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
/* Parameter names and values are taken from igmp-v2-06 draft */ /* Parameter names and values are taken from igmp-v2-06 draft */
...@@ -433,6 +427,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, ...@@ -433,6 +427,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
int type, int gdeleted, int sdeleted) int type, int gdeleted, int sdeleted)
{ {
struct net_device *dev = pmc->interface->dev; struct net_device *dev = pmc->interface->dev;
struct net *net = dev_net(dev);
struct igmpv3_report *pih; struct igmpv3_report *pih;
struct igmpv3_grec *pgr = NULL; struct igmpv3_grec *pgr = NULL;
struct ip_sf_list *psf, *psf_next, *psf_prev, **psf_list; struct ip_sf_list *psf, *psf_next, *psf_prev, **psf_list;
...@@ -440,7 +435,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, ...@@ -440,7 +435,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
if (pmc->multiaddr == IGMP_ALL_HOSTS) if (pmc->multiaddr == IGMP_ALL_HOSTS)
return skb; return skb;
if (ipv4_is_local_multicast(pmc->multiaddr) && !sysctl_igmp_llm_reports) if (ipv4_is_local_multicast(pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)
return skb; return skb;
isquery = type == IGMPV3_MODE_IS_INCLUDE || isquery = type == IGMPV3_MODE_IS_INCLUDE ||
...@@ -543,6 +538,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, ...@@ -543,6 +538,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc) static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc)
{ {
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct net *net = dev_net(in_dev->dev);
int type; int type;
if (!pmc) { if (!pmc) {
...@@ -551,7 +547,7 @@ static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc) ...@@ -551,7 +547,7 @@ static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc)
if (pmc->multiaddr == IGMP_ALL_HOSTS) if (pmc->multiaddr == IGMP_ALL_HOSTS)
continue; continue;
if (ipv4_is_local_multicast(pmc->multiaddr) && if (ipv4_is_local_multicast(pmc->multiaddr) &&
!sysctl_igmp_llm_reports) !net->ipv4.sysctl_igmp_llm_reports)
continue; continue;
spin_lock_bh(&pmc->lock); spin_lock_bh(&pmc->lock);
if (pmc->sfcount[MCAST_EXCLUDE]) if (pmc->sfcount[MCAST_EXCLUDE])
...@@ -687,7 +683,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, ...@@ -687,7 +683,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
if (type == IGMPV3_HOST_MEMBERSHIP_REPORT) if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
return igmpv3_send_report(in_dev, pmc); return igmpv3_send_report(in_dev, pmc);
if (ipv4_is_local_multicast(group) && !sysctl_igmp_llm_reports) if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports)
return 0; return 0;
if (type == IGMP_HOST_LEAVE_MESSAGE) if (type == IGMP_HOST_LEAVE_MESSAGE)
...@@ -766,9 +762,10 @@ static void igmp_ifc_timer_expire(unsigned long data) ...@@ -766,9 +762,10 @@ static void igmp_ifc_timer_expire(unsigned long data)
static void igmp_ifc_event(struct in_device *in_dev) static void igmp_ifc_event(struct in_device *in_dev)
{ {
struct net *net = dev_net(in_dev->dev);
if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev))
return; return;
in_dev->mr_ifc_count = in_dev->mr_qrv ?: sysctl_igmp_qrv; in_dev->mr_ifc_count = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
igmp_ifc_start_timer(in_dev, 1); igmp_ifc_start_timer(in_dev, 1);
} }
...@@ -858,12 +855,13 @@ static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs) ...@@ -858,12 +855,13 @@ static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
static bool igmp_heard_report(struct in_device *in_dev, __be32 group) static bool igmp_heard_report(struct in_device *in_dev, __be32 group)
{ {
struct ip_mc_list *im; struct ip_mc_list *im;
struct net *net = dev_net(in_dev->dev);
/* Timers are only set for non-local groups */ /* Timers are only set for non-local groups */
if (group == IGMP_ALL_HOSTS) if (group == IGMP_ALL_HOSTS)
return false; return false;
if (ipv4_is_local_multicast(group) && !sysctl_igmp_llm_reports) if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports)
return false; return false;
rcu_read_lock(); rcu_read_lock();
...@@ -887,6 +885,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, ...@@ -887,6 +885,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
__be32 group = ih->group; __be32 group = ih->group;
int max_delay; int max_delay;
int mark = 0; int mark = 0;
struct net *net = dev_net(in_dev->dev);
if (len == 8) { if (len == 8) {
...@@ -972,7 +971,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, ...@@ -972,7 +971,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
if (im->multiaddr == IGMP_ALL_HOSTS) if (im->multiaddr == IGMP_ALL_HOSTS)
continue; continue;
if (ipv4_is_local_multicast(im->multiaddr) && if (ipv4_is_local_multicast(im->multiaddr) &&
!sysctl_igmp_llm_reports) !net->ipv4.sysctl_igmp_llm_reports)
continue; continue;
spin_lock_bh(&im->lock); spin_lock_bh(&im->lock);
if (im->tm_running) if (im->tm_running)
...@@ -1088,6 +1087,7 @@ static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr) ...@@ -1088,6 +1087,7 @@ static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr)
static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im) static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im)
{ {
struct ip_mc_list *pmc; struct ip_mc_list *pmc;
struct net *net = dev_net(in_dev->dev);
/* this is an "ip_mc_list" for convenience; only the fields below /* this is an "ip_mc_list" for convenience; only the fields below
* are actually used. In particular, the refcnt and users are not * are actually used. In particular, the refcnt and users are not
...@@ -1102,7 +1102,7 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im) ...@@ -1102,7 +1102,7 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im)
pmc->interface = im->interface; pmc->interface = im->interface;
in_dev_hold(in_dev); in_dev_hold(in_dev);
pmc->multiaddr = im->multiaddr; pmc->multiaddr = im->multiaddr;
pmc->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
pmc->sfmode = im->sfmode; pmc->sfmode = im->sfmode;
if (pmc->sfmode == MCAST_INCLUDE) { if (pmc->sfmode == MCAST_INCLUDE) {
struct ip_sf_list *psf; struct ip_sf_list *psf;
...@@ -1187,6 +1187,7 @@ static void igmp_group_dropped(struct ip_mc_list *im) ...@@ -1187,6 +1187,7 @@ static void igmp_group_dropped(struct ip_mc_list *im)
{ {
struct in_device *in_dev = im->interface; struct in_device *in_dev = im->interface;
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
struct net *net = dev_net(in_dev->dev);
int reporter; int reporter;
#endif #endif
...@@ -1198,7 +1199,7 @@ static void igmp_group_dropped(struct ip_mc_list *im) ...@@ -1198,7 +1199,7 @@ static void igmp_group_dropped(struct ip_mc_list *im)
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
if (im->multiaddr == IGMP_ALL_HOSTS) if (im->multiaddr == IGMP_ALL_HOSTS)
return; return;
if (ipv4_is_local_multicast(im->multiaddr) && !sysctl_igmp_llm_reports) if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)
return; return;
reporter = im->reporter; reporter = im->reporter;
...@@ -1223,6 +1224,7 @@ static void igmp_group_dropped(struct ip_mc_list *im) ...@@ -1223,6 +1224,7 @@ static void igmp_group_dropped(struct ip_mc_list *im)
static void igmp_group_added(struct ip_mc_list *im) static void igmp_group_added(struct ip_mc_list *im)
{ {
struct in_device *in_dev = im->interface; struct in_device *in_dev = im->interface;
struct net *net = dev_net(in_dev->dev);
if (im->loaded == 0) { if (im->loaded == 0) {
im->loaded = 1; im->loaded = 1;
...@@ -1232,7 +1234,7 @@ static void igmp_group_added(struct ip_mc_list *im) ...@@ -1232,7 +1234,7 @@ static void igmp_group_added(struct ip_mc_list *im)
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
if (im->multiaddr == IGMP_ALL_HOSTS) if (im->multiaddr == IGMP_ALL_HOSTS)
return; return;
if (ipv4_is_local_multicast(im->multiaddr) && !sysctl_igmp_llm_reports) if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)
return; return;
if (in_dev->dead) if (in_dev->dead)
...@@ -1245,7 +1247,7 @@ static void igmp_group_added(struct ip_mc_list *im) ...@@ -1245,7 +1247,7 @@ static void igmp_group_added(struct ip_mc_list *im)
} }
/* else, v3 */ /* else, v3 */
im->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
igmp_ifc_event(in_dev); igmp_ifc_event(in_dev);
#endif #endif
} }
...@@ -1314,6 +1316,7 @@ static void ip_mc_hash_remove(struct in_device *in_dev, ...@@ -1314,6 +1316,7 @@ static void ip_mc_hash_remove(struct in_device *in_dev,
void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
{ {
struct ip_mc_list *im; struct ip_mc_list *im;
struct net *net = dev_net(in_dev->dev);
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -1340,7 +1343,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) ...@@ -1340,7 +1343,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
spin_lock_init(&im->lock); spin_lock_init(&im->lock);
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
setup_timer(&im->timer, igmp_timer_expire, (unsigned long)im); setup_timer(&im->timer, igmp_timer_expire, (unsigned long)im);
im->unsolicit_count = sysctl_igmp_qrv; im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;
#endif #endif
im->next_rcu = in_dev->mc_list; im->next_rcu = in_dev->mc_list;
...@@ -1533,6 +1536,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev) ...@@ -1533,6 +1536,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev)
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
struct ip_mc_list *im; struct ip_mc_list *im;
int type; int type;
struct net *net = dev_net(in_dev->dev);
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -1540,7 +1544,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev) ...@@ -1540,7 +1544,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev)
if (im->multiaddr == IGMP_ALL_HOSTS) if (im->multiaddr == IGMP_ALL_HOSTS)
continue; continue;
if (ipv4_is_local_multicast(im->multiaddr) && if (ipv4_is_local_multicast(im->multiaddr) &&
!sysctl_igmp_llm_reports) !net->ipv4.sysctl_igmp_llm_reports)
continue; continue;
/* a failover is happening and switches /* a failover is happening and switches
...@@ -1639,6 +1643,7 @@ void ip_mc_down(struct in_device *in_dev) ...@@ -1639,6 +1643,7 @@ void ip_mc_down(struct in_device *in_dev)
void ip_mc_init_dev(struct in_device *in_dev) void ip_mc_init_dev(struct in_device *in_dev)
{ {
struct net *net = dev_net(in_dev->dev);
ASSERT_RTNL(); ASSERT_RTNL();
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
...@@ -1646,7 +1651,7 @@ void ip_mc_init_dev(struct in_device *in_dev) ...@@ -1646,7 +1651,7 @@ void ip_mc_init_dev(struct in_device *in_dev)
(unsigned long)in_dev); (unsigned long)in_dev);
setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire,
(unsigned long)in_dev); (unsigned long)in_dev);
in_dev->mr_qrv = sysctl_igmp_qrv; in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv;
#endif #endif
spin_lock_init(&in_dev->mc_tomb_lock); spin_lock_init(&in_dev->mc_tomb_lock);
...@@ -1657,11 +1662,12 @@ void ip_mc_init_dev(struct in_device *in_dev) ...@@ -1657,11 +1662,12 @@ void ip_mc_init_dev(struct in_device *in_dev)
void ip_mc_up(struct in_device *in_dev) void ip_mc_up(struct in_device *in_dev)
{ {
struct ip_mc_list *pmc; struct ip_mc_list *pmc;
struct net *net = dev_net(in_dev->dev);
ASSERT_RTNL(); ASSERT_RTNL();
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
in_dev->mr_qrv = sysctl_igmp_qrv; in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv;
#endif #endif
ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS);
...@@ -1727,11 +1733,6 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) ...@@ -1727,11 +1733,6 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr)
/* /*
* Join a socket to a group * Join a socket to a group
*/ */
int sysctl_igmp_max_memberships __read_mostly = IP_MAX_MEMBERSHIPS;
int sysctl_igmp_max_msf __read_mostly = IP_MAX_MSF;
#ifdef CONFIG_IP_MULTICAST
int sysctl_igmp_qrv __read_mostly = IGMP_QUERY_ROBUSTNESS_VARIABLE;
#endif
static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
__be32 *psfsrc) __be32 *psfsrc)
...@@ -1756,6 +1757,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, ...@@ -1756,6 +1757,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) { if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) {
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
struct in_device *in_dev = pmc->interface; struct in_device *in_dev = pmc->interface;
struct net *net = dev_net(in_dev->dev);
#endif #endif
/* no more filters for this source */ /* no more filters for this source */
...@@ -1766,7 +1768,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, ...@@ -1766,7 +1768,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
if (psf->sf_oldin && if (psf->sf_oldin &&
!IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) { !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
psf->sf_crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
psf->sf_next = pmc->tomb; psf->sf_next = pmc->tomb;
pmc->tomb = psf; pmc->tomb = psf;
rv = 1; rv = 1;
...@@ -1824,12 +1826,13 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode, ...@@ -1824,12 +1826,13 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
pmc->sfcount[MCAST_INCLUDE]) { pmc->sfcount[MCAST_INCLUDE]) {
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
struct ip_sf_list *psf; struct ip_sf_list *psf;
struct net *net = dev_net(in_dev->dev);
#endif #endif
/* filter mode change */ /* filter mode change */
pmc->sfmode = MCAST_INCLUDE; pmc->sfmode = MCAST_INCLUDE;
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
pmc->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
in_dev->mr_ifc_count = pmc->crcount; in_dev->mr_ifc_count = pmc->crcount;
for (psf = pmc->sources; psf; psf = psf->sf_next) for (psf = pmc->sources; psf; psf = psf->sf_next)
psf->sf_crcount = 0; psf->sf_crcount = 0;
...@@ -1996,6 +1999,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, ...@@ -1996,6 +1999,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
} else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) { } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
struct ip_sf_list *psf; struct ip_sf_list *psf;
struct net *net = dev_net(pmc->interface->dev);
in_dev = pmc->interface; in_dev = pmc->interface;
#endif #endif
...@@ -2007,7 +2011,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, ...@@ -2007,7 +2011,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
/* else no filters; keep old mode for reports */ /* else no filters; keep old mode for reports */
pmc->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv; pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
in_dev->mr_ifc_count = pmc->crcount; in_dev->mr_ifc_count = pmc->crcount;
for (psf = pmc->sources; psf; psf = psf->sf_next) for (psf = pmc->sources; psf; psf = psf->sf_next)
psf->sf_crcount = 0; psf->sf_crcount = 0;
...@@ -2074,7 +2078,7 @@ int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr) ...@@ -2074,7 +2078,7 @@ int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr)
count++; count++;
} }
err = -ENOBUFS; err = -ENOBUFS;
if (count >= sysctl_igmp_max_memberships) if (count >= net->ipv4.sysctl_igmp_max_memberships)
goto done; goto done;
iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL); iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);
if (!iml) if (!iml)
...@@ -2246,7 +2250,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct ...@@ -2246,7 +2250,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
} }
/* else, add a new source to the filter */ /* else, add a new source to the filter */
if (psl && psl->sl_count >= sysctl_igmp_max_msf) { if (psl && psl->sl_count >= net->ipv4.sysctl_igmp_max_msf) {
err = -ENOBUFS; err = -ENOBUFS;
goto done; goto done;
} }
......
...@@ -571,6 +571,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -571,6 +571,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
int optname, char __user *optval, unsigned int optlen) int optname, char __user *optval, unsigned int optlen)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct net *net = sock_net(sk);
int val = 0, err; int val = 0, err;
bool needs_rtnl = setsockopt_needs_rtnl(optname); bool needs_rtnl = setsockopt_needs_rtnl(optname);
...@@ -910,7 +911,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -910,7 +911,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
} }
/* numsrc >= (1G-4) overflow in 32 bits */ /* numsrc >= (1G-4) overflow in 32 bits */
if (msf->imsf_numsrc >= 0x3ffffffcU || if (msf->imsf_numsrc >= 0x3ffffffcU ||
msf->imsf_numsrc > sysctl_igmp_max_msf) { msf->imsf_numsrc > net->ipv4.sysctl_igmp_max_msf) {
kfree(msf); kfree(msf);
err = -ENOBUFS; err = -ENOBUFS;
break; break;
...@@ -1065,7 +1066,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -1065,7 +1066,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
/* numsrc >= (4G-140)/128 overflow in 32 bits */ /* numsrc >= (4G-140)/128 overflow in 32 bits */
if (gsf->gf_numsrc >= 0x1ffffff || if (gsf->gf_numsrc >= 0x1ffffff ||
gsf->gf_numsrc > sysctl_igmp_max_msf) { gsf->gf_numsrc > net->ipv4.sysctl_igmp_max_msf) {
err = -ENOBUFS; err = -ENOBUFS;
goto mc_msf_out; goto mc_msf_out;
} }
......
...@@ -367,30 +367,6 @@ static struct ctl_table ipv4_table[] = { ...@@ -367,30 +367,6 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec
}, },
{
.procname = "igmp_max_memberships",
.data = &sysctl_igmp_max_memberships,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec
},
{
.procname = "igmp_max_msf",
.data = &sysctl_igmp_max_msf,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec
},
#ifdef CONFIG_IP_MULTICAST
{
.procname = "igmp_qrv",
.data = &sysctl_igmp_qrv,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &one
},
#endif
{ {
.procname = "inet_peer_threshold", .procname = "inet_peer_threshold",
.data = &inet_peer_threshold, .data = &inet_peer_threshold,
...@@ -866,11 +842,35 @@ static struct ctl_table ipv4_net_table[] = { ...@@ -866,11 +842,35 @@ static struct ctl_table ipv4_net_table[] = {
}, },
{ {
.procname = "igmp_link_local_mcast_reports", .procname = "igmp_link_local_mcast_reports",
.data = &sysctl_igmp_llm_reports, .data = &init_net.ipv4.sysctl_igmp_llm_reports,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec
}, },
{
.procname = "igmp_max_memberships",
.data = &init_net.ipv4.sysctl_igmp_max_memberships,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec
},
{
.procname = "igmp_max_msf",
.data = &init_net.ipv4.sysctl_igmp_max_msf,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec
},
#ifdef CONFIG_IP_MULTICAST
{
.procname = "igmp_qrv",
.data = &init_net.ipv4.sysctl_igmp_qrv,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &one
},
#endif
{ {
.procname = "tcp_keepalive_time", .procname = "tcp_keepalive_time",
.data = &init_net.ipv4.sysctl_tcp_keepalive_time, .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
......
...@@ -2399,6 +2399,12 @@ static int __net_init tcp_sk_init(struct net *net) ...@@ -2399,6 +2399,12 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT; net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX; net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX;
net->ipv4.sysctl_igmp_max_memberships = 20;
net->ipv4.sysctl_igmp_max_msf = 10;
/* IGMP reports for link-local multicast groups are enabled by default */
net->ipv4.sysctl_igmp_llm_reports = 1;
net->ipv4.sysctl_igmp_qrv = 2;
return 0; return 0;
fail: fail:
tcp_sk_exit(net); tcp_sk_exit(net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment