aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2012-10-29 00:53:27 -0400
committerDavid S. Miller <davem@davemloft.net>2012-11-01 12:41:34 -0400
commitcc535dfb6a85b42218307c43f60668d7bd6f4318 (patch)
tree168228e4048e5050a71c311f3d2b6af7349f9954
parentb77bc2069d1e437d5a1a71bb5cfcf4556ee40015 (diff)
rtnl/ipv4: use netconf msg to advertise rp_filter status
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/netconf.h1
-rw-r--r--net/ipv4/devinet.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/include/uapi/linux/netconf.h b/include/uapi/linux/netconf.h
index d0513726711f..75dcbc587fb5 100644
--- a/include/uapi/linux/netconf.h
+++ b/include/uapi/linux/netconf.h
@@ -12,6 +12,7 @@ enum {
12 NETCONFA_UNSPEC, 12 NETCONFA_UNSPEC,
13 NETCONFA_IFINDEX, 13 NETCONFA_IFINDEX,
14 NETCONFA_FORWARDING, 14 NETCONFA_FORWARDING,
15 NETCONFA_RP_FILTER,
15 __NETCONFA_MAX 16 __NETCONFA_MAX
16}; 17};
17#define NETCONFA_MAX (__NETCONFA_MAX - 1) 18#define NETCONFA_MAX (__NETCONFA_MAX - 1)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index f8b1e0494d75..f6db227c1fd9 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1451,6 +1451,8 @@ static int inet_netconf_msgsize_devconf(int type)
1451 /* type -1 is used for ALL */ 1451 /* type -1 is used for ALL */
1452 if (type == -1 || type == NETCONFA_FORWARDING) 1452 if (type == -1 || type == NETCONFA_FORWARDING)
1453 size += nla_total_size(4); 1453 size += nla_total_size(4);
1454 if (type == -1 || type == NETCONFA_RP_FILTER)
1455 size += nla_total_size(4);
1454 1456
1455 return size; 1457 return size;
1456} 1458}
@@ -1479,6 +1481,10 @@ static int inet_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
1479 nla_put_s32(skb, NETCONFA_FORWARDING, 1481 nla_put_s32(skb, NETCONFA_FORWARDING,
1480 IPV4_DEVCONF(*devconf, FORWARDING)) < 0) 1482 IPV4_DEVCONF(*devconf, FORWARDING)) < 0)
1481 goto nla_put_failure; 1483 goto nla_put_failure;
1484 if ((type == -1 || type == NETCONFA_RP_FILTER) &&
1485 nla_put_s32(skb, NETCONFA_RP_FILTER,
1486 IPV4_DEVCONF(*devconf, RP_FILTER)) < 0)
1487 goto nla_put_failure;
1482 1488
1483 return nlmsg_end(skb, nlh); 1489 return nlmsg_end(skb, nlh);
1484 1490
@@ -1515,6 +1521,7 @@ errout:
1515static const struct nla_policy devconf_ipv4_policy[NETCONFA_MAX+1] = { 1521static const struct nla_policy devconf_ipv4_policy[NETCONFA_MAX+1] = {
1516 [NETCONFA_IFINDEX] = { .len = sizeof(int) }, 1522 [NETCONFA_IFINDEX] = { .len = sizeof(int) },
1517 [NETCONFA_FORWARDING] = { .len = sizeof(int) }, 1523 [NETCONFA_FORWARDING] = { .len = sizeof(int) },
1524 [NETCONFA_RP_FILTER] = { .len = sizeof(int) },
1518}; 1525};
1519 1526
1520static int inet_netconf_get_devconf(struct sk_buff *in_skb, 1527static int inet_netconf_get_devconf(struct sk_buff *in_skb,
@@ -1647,6 +1654,23 @@ static int devinet_conf_proc(ctl_table *ctl, int write,
1647 i == IPV4_DEVCONF_ROUTE_LOCALNET - 1) 1654 i == IPV4_DEVCONF_ROUTE_LOCALNET - 1)
1648 if ((new_value == 0) && (old_value != 0)) 1655 if ((new_value == 0) && (old_value != 0))
1649 rt_cache_flush(net); 1656 rt_cache_flush(net);
1657 if (i == IPV4_DEVCONF_RP_FILTER - 1 &&
1658 new_value != old_value) {
1659 int ifindex;
1660
1661 if (cnf == net->ipv4.devconf_dflt)
1662 ifindex = NETCONFA_IFINDEX_DEFAULT;
1663 else if (cnf == net->ipv4.devconf_all)
1664 ifindex = NETCONFA_IFINDEX_ALL;
1665 else {
1666 struct in_device *idev =
1667 container_of(cnf, struct in_device,
1668 cnf);
1669 ifindex = idev->dev->ifindex;
1670 }
1671 inet_netconf_notify_devconf(net, NETCONFA_RP_FILTER,
1672 ifindex, cnf);
1673 }
1650 } 1674 }
1651 1675
1652 return ret; 1676 return ret;