net ipv4: Decouple ipv4 interface parameters from binary sysctl numbers
Stop using the binary sysctl enumeartion in sysctl.h as an index into a per interface array. This leads to unnecessary binary sysctl number allocation, and a fragility in data structure and implementation because of unnecessary coupling. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
9e3f8063a7
commit
02291680ff
@@ -10,10 +10,40 @@
|
||||
#include <linux/timer.h>
|
||||
#include <linux/sysctl.h>
|
||||
|
||||
enum
|
||||
{
|
||||
IPV4_DEVCONF_FORWARDING=1,
|
||||
IPV4_DEVCONF_MC_FORWARDING,
|
||||
IPV4_DEVCONF_PROXY_ARP,
|
||||
IPV4_DEVCONF_ACCEPT_REDIRECTS,
|
||||
IPV4_DEVCONF_SECURE_REDIRECTS,
|
||||
IPV4_DEVCONF_SEND_REDIRECTS,
|
||||
IPV4_DEVCONF_SHARED_MEDIA,
|
||||
IPV4_DEVCONF_RP_FILTER,
|
||||
IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
|
||||
IPV4_DEVCONF_BOOTP_RELAY,
|
||||
IPV4_DEVCONF_LOG_MARTIANS,
|
||||
IPV4_DEVCONF_TAG,
|
||||
IPV4_DEVCONF_ARPFILTER,
|
||||
IPV4_DEVCONF_MEDIUM_ID,
|
||||
IPV4_DEVCONF_NOXFRM,
|
||||
IPV4_DEVCONF_NOPOLICY,
|
||||
IPV4_DEVCONF_FORCE_IGMP_VERSION,
|
||||
IPV4_DEVCONF_ARP_ANNOUNCE,
|
||||
IPV4_DEVCONF_ARP_IGNORE,
|
||||
IPV4_DEVCONF_PROMOTE_SECONDARIES,
|
||||
IPV4_DEVCONF_ARP_ACCEPT,
|
||||
IPV4_DEVCONF_ARP_NOTIFY,
|
||||
IPV4_DEVCONF_ACCEPT_LOCAL,
|
||||
IPV4_DEVCONF_SRC_VMARK,
|
||||
IPV4_DEVCONF_PROXY_ARP_PVLAN,
|
||||
__IPV4_DEVCONF_MAX
|
||||
};
|
||||
|
||||
struct ipv4_devconf {
|
||||
void *sysctl;
|
||||
int data[__NET_IPV4_CONF_MAX - 1];
|
||||
DECLARE_BITMAP(state, __NET_IPV4_CONF_MAX - 1);
|
||||
int data[__IPV4_DEVCONF_MAX - 1];
|
||||
DECLARE_BITMAP(state, __IPV4_DEVCONF_MAX - 1);
|
||||
};
|
||||
|
||||
struct in_device {
|
||||
@@ -40,7 +70,7 @@ struct in_device {
|
||||
struct rcu_head rcu_head;
|
||||
};
|
||||
|
||||
#define IPV4_DEVCONF(cnf, attr) ((cnf).data[NET_IPV4_CONF_ ## attr - 1])
|
||||
#define IPV4_DEVCONF(cnf, attr) ((cnf).data[IPV4_DEVCONF_ ## attr - 1])
|
||||
#define IPV4_DEVCONF_ALL(net, attr) \
|
||||
IPV4_DEVCONF((*(net)->ipv4.devconf_all), attr)
|
||||
|
||||
@@ -60,13 +90,13 @@ static inline void ipv4_devconf_set(struct in_device *in_dev, int index,
|
||||
|
||||
static inline void ipv4_devconf_setall(struct in_device *in_dev)
|
||||
{
|
||||
bitmap_fill(in_dev->cnf.state, __NET_IPV4_CONF_MAX - 1);
|
||||
bitmap_fill(in_dev->cnf.state, __IPV4_DEVCONF_MAX - 1);
|
||||
}
|
||||
|
||||
#define IN_DEV_CONF_GET(in_dev, attr) \
|
||||
ipv4_devconf_get((in_dev), NET_IPV4_CONF_ ## attr)
|
||||
ipv4_devconf_get((in_dev), IPV4_DEVCONF_ ## attr)
|
||||
#define IN_DEV_CONF_SET(in_dev, attr, val) \
|
||||
ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val))
|
||||
ipv4_devconf_set((in_dev), IPV4_DEVCONF_ ## attr, (val))
|
||||
|
||||
#define IN_DEV_ANDCONF(in_dev, attr) \
|
||||
(IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) && \
|
||||
|
Reference in New Issue
Block a user