[PATCH 2/4] [IPV4]: Convert IPv4 devconf to an array

2007-06-05 Thread Herbert Xu
[IPV4]: Convert IPv4 devconf to an array

This patch converts the ipv4_devconf config members (everything except
sysctl) to an array.  This allows easier manipulation which will be
needed later on to provide better management of default config values.

Signed-off-by: Herbert Xu [EMAIL PROTECTED]
---

 drivers/infiniband/hw/amso1100/c2.c |2 
 include/linux/inetdevice.h  |   94 +++-
 net/ipv4/arp.c  |   11 -
 net/ipv4/devinet.c  |  264 ++--
 net/ipv4/igmp.c |   18 +-
 net/ipv4/ipmr.c |   12 -
 net/ipv4/proc.c |2 
 net/ipv4/route.c|   14 -
 net/ipv4/sysctl_net_ipv4.c  |6 
 9 files changed, 163 insertions(+), 260 deletions(-)

diff --git a/drivers/infiniband/hw/amso1100/c2.c 
b/drivers/infiniband/hw/amso1100/c2.c
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -672,7 +672,7 @@ static int c2_up(struct net_device *netd
 * rdma interface.
 */
in_dev = in_dev_get(netdev);
-   in_dev-cnf.arp_ignore = 1;
+   IN_DEV_CONF_SET(in_dev, ARP_IGNORE, 1);
in_dev_put(in_dev);
 
return 0;
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -10,28 +10,8 @@
 
 struct ipv4_devconf
 {
-   int accept_redirects;
-   int send_redirects;
-   int secure_redirects;
-   int shared_media;
-   int accept_source_route;
-   int rp_filter;
-   int proxy_arp;
-   int bootp_relay;
-   int log_martians;
-   int forwarding;
-   int mc_forwarding;
-   int tag;
-   int arp_filter;
-   int arp_announce;
-   int arp_ignore;
-   int arp_accept;
-   int medium_id;
-   int no_xfrm;
-   int no_policy;
-   int force_igmp_version;
-   int promote_secondaries;
void*sysctl;
+   int data[__NET_IPV4_CONF_MAX - 1];
 };
 
 extern struct ipv4_devconf ipv4_devconf;
@@ -60,30 +40,64 @@ struct in_device
struct rcu_head rcu_head;
 };
 
-#define IN_DEV_FORWARD(in_dev) ((in_dev)-cnf.forwarding)
-#define IN_DEV_MFORWARD(in_dev)(ipv4_devconf.mc_forwarding  
(in_dev)-cnf.mc_forwarding)
-#define IN_DEV_RPFILTER(in_dev)(ipv4_devconf.rp_filter  
(in_dev)-cnf.rp_filter)
-#define IN_DEV_SOURCE_ROUTE(in_dev)(ipv4_devconf.accept_source_route  
(in_dev)-cnf.accept_source_route)
-#define IN_DEV_BOOTP_RELAY(in_dev) (ipv4_devconf.bootp_relay  
(in_dev)-cnf.bootp_relay)
-
-#define IN_DEV_LOG_MARTIANS(in_dev)(ipv4_devconf.log_martians || 
(in_dev)-cnf.log_martians)
-#define IN_DEV_PROXY_ARP(in_dev)   (ipv4_devconf.proxy_arp || 
(in_dev)-cnf.proxy_arp)
-#define IN_DEV_SHARED_MEDIA(in_dev)(ipv4_devconf.shared_media || 
(in_dev)-cnf.shared_media)
-#define IN_DEV_TX_REDIRECTS(in_dev)(ipv4_devconf.send_redirects || 
(in_dev)-cnf.send_redirects)
-#define IN_DEV_SEC_REDIRECTS(in_dev)   (ipv4_devconf.secure_redirects || 
(in_dev)-cnf.secure_redirects)
-#define IN_DEV_IDTAG(in_dev)   ((in_dev)-cnf.tag)
-#define IN_DEV_MEDIUM_ID(in_dev)   ((in_dev)-cnf.medium_id)
-#define IN_DEV_PROMOTE_SECONDARIES(in_dev) 
(ipv4_devconf.promote_secondaries || (in_dev)-cnf.promote_secondaries)
+#define IPV4_DEVCONF(cnf, attr) ((cnf).data[NET_IPV4_CONF_ ## attr - 1])
+#define IPV4_DEVCONF_ALL(attr) IPV4_DEVCONF(ipv4_devconf, attr)
+
+static inline int ipv4_devconf_get(struct in_device *in_dev, int index)
+{
+   index--;
+   return in_dev-cnf.data[index];
+}
+
+static inline void ipv4_devconf_set(struct in_device *in_dev, int index,
+   int val)
+{
+   index--;
+   in_dev-cnf.data[index] = val;
+}
+
+#define IN_DEV_CONF_GET(in_dev, attr) \
+   ipv4_devconf_get((in_dev), NET_IPV4_CONF_ ## attr)
+#define IN_DEV_CONF_SET(in_dev, attr, val) \
+   ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val))
+
+#define IN_DEV_ANDCONF(in_dev, attr) \
+   (IPV4_DEVCONF_ALL(attr)  IN_DEV_CONF_GET((in_dev), attr))
+#define IN_DEV_ORCONF(in_dev, attr) \
+   (IPV4_DEVCONF_ALL(attr) || IN_DEV_CONF_GET((in_dev), attr))
+#define IN_DEV_MAXCONF(in_dev, attr) \
+   (max(IPV4_DEVCONF_ALL(attr), IN_DEV_CONF_GET((in_dev), attr)))
+
+#define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING)
+#define IN_DEV_MFORWARD(in_dev)
(IPV4_DEVCONF_ALL(MC_FORWARDING)  \
+IPV4_DEVCONF((in_dev)-cnf, \
+ MC_FORWARDING))
+#define IN_DEV_RPFILTER(in_dev)IN_DEV_ANDCONF((in_dev), 
RP_FILTER)
+#define IN_DEV_SOURCE_ROUTE(in_dev)IN_DEV_ANDCONF((in_dev), \
+  

Re: [PATCH 2/4] [IPV4]: Convert IPv4 devconf to an array

2007-06-05 Thread David Miller
From: Herbert Xu [EMAIL PROTECTED]
Date: Tue, 05 Jun 2007 16:31:02 +1000

 [IPV4]: Convert IPv4 devconf to an array
 
 This patch converts the ipv4_devconf config members (everything except
 sysctl) to an array.  This allows easier manipulation which will be
 needed later on to provide better management of default config values.
 
 Signed-off-by: Herbert Xu [EMAIL PROTECTED]

Applied, thanks.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html