netconf: add proxy-arp support
authorstephen hemminger <stephen@networkplumber.org>
Thu, 12 Dec 2013 21:06:50 +0000 (13:06 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 14 Dec 2013 05:58:22 +0000 (00:58 -0500)
Add support to netconf to show changes to proxy-arp status on a per
interface basis via netlink in a manner similar to forwarding
and reverse path state.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/netconf.h
net/ipv4/devinet.c

index 64804a798b0c826aeb912c517e9f2ecd4c6cc5da..bd969d77ce5203125b815b78eb6c7237d011f6c4 100644 (file)
@@ -14,6 +14,7 @@ enum {
        NETCONFA_FORWARDING,
        NETCONFA_RP_FILTER,
        NETCONFA_MC_FORWARDING,
+       NETCONFA_PROXY_ARP,
        __NETCONFA_MAX
 };
 #define NETCONFA_MAX   (__NETCONFA_MAX - 1)
index 84956f5f01352a8684101fa3eb2528740f7f5934..de03fe7002d049b9726a2329231f7dee8903c5f5 100644 (file)
@@ -1696,6 +1696,8 @@ static int inet_netconf_msgsize_devconf(int type)
                size += nla_total_size(4);
        if (type == -1 || type == NETCONFA_MC_FORWARDING)
                size += nla_total_size(4);
+       if (type == -1 || type == NETCONFA_PROXY_ARP)
+               size += nla_total_size(4);
 
        return size;
 }
@@ -1732,6 +1734,10 @@ static int inet_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
            nla_put_s32(skb, NETCONFA_MC_FORWARDING,
                        IPV4_DEVCONF(*devconf, MC_FORWARDING)) < 0)
                goto nla_put_failure;
+       if ((type == -1 || type == NETCONFA_PROXY_ARP) &&
+           nla_put_s32(skb, NETCONFA_PROXY_ARP,
+                       IPV4_DEVCONF(*devconf, PROXY_ARP)) < 0)
+               goto nla_put_failure;
 
        return nlmsg_end(skb, nlh);
 
@@ -1769,6 +1775,7 @@ static const struct nla_policy devconf_ipv4_policy[NETCONFA_MAX+1] = {
        [NETCONFA_IFINDEX]      = { .len = sizeof(int) },
        [NETCONFA_FORWARDING]   = { .len = sizeof(int) },
        [NETCONFA_RP_FILTER]    = { .len = sizeof(int) },
+       [NETCONFA_PROXY_ARP]    = { .len = sizeof(int) },
 };
 
 static int inet_netconf_get_devconf(struct sk_buff *in_skb,
@@ -1950,6 +1957,19 @@ static void inet_forward_change(struct net *net)
        }
 }
 
+static int devinet_conf_ifindex(struct net *net, struct ipv4_devconf *cnf)
+{
+       if (cnf == net->ipv4.devconf_dflt)
+               return NETCONFA_IFINDEX_DEFAULT;
+       else if (cnf == net->ipv4.devconf_all)
+               return NETCONFA_IFINDEX_ALL;
+       else {
+               struct in_device *idev
+                       = container_of(cnf, struct in_device, cnf);
+               return idev->dev->ifindex;
+       }
+}
+
 static int devinet_conf_proc(struct ctl_table *ctl, int write,
                             void __user *buffer,
                             size_t *lenp, loff_t *ppos)
@@ -1962,6 +1982,7 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,
                struct ipv4_devconf *cnf = ctl->extra1;
                struct net *net = ctl->extra2;
                int i = (int *)ctl->data - cnf->data;
+               int ifindex;
 
                set_bit(i, cnf->state);
 
@@ -1971,23 +1992,19 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,
                    i == IPV4_DEVCONF_ROUTE_LOCALNET - 1)
                        if ((new_value == 0) && (old_value != 0))
                                rt_cache_flush(net);
+
                if (i == IPV4_DEVCONF_RP_FILTER - 1 &&
                    new_value != old_value) {
-                       int ifindex;
-
-                       if (cnf == net->ipv4.devconf_dflt)
-                               ifindex = NETCONFA_IFINDEX_DEFAULT;
-                       else if (cnf == net->ipv4.devconf_all)
-                               ifindex = NETCONFA_IFINDEX_ALL;
-                       else {
-                               struct in_device *idev =
-                                       container_of(cnf, struct in_device,
-                                                    cnf);
-                               ifindex = idev->dev->ifindex;
-                       }
+                       ifindex = devinet_conf_ifindex(net, cnf);
                        inet_netconf_notify_devconf(net, NETCONFA_RP_FILTER,
                                                    ifindex, cnf);
                }
+               if (i == IPV4_DEVCONF_PROXY_ARP - 1 &&
+                   new_value != old_value) {
+                       ifindex = devinet_conf_ifindex(net, cnf);
+                       inet_netconf_notify_devconf(net, NETCONFA_PROXY_ARP,
+                                                   ifindex, cnf);
+               }
        }
 
        return ret;