From: Ben Pfaff Date: Fri, 8 May 2009 18:24:58 +0000 (-0700) Subject: datapath: Omit sysfs-specific data when sysfs is not enabled or not supported. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca2ef52a6965866fc38d52022901a605919dec9;p=openvswitch datapath: Omit sysfs-specific data when sysfs is not enabled or not supported. This saves a few bytes of memory but it also makes it clear to the reader what data is used for what. --- diff --git a/datapath/brc_sysfs.h b/datapath/brc_sysfs.h index 8a550e3c..0c72fb22 100644 --- a/datapath/brc_sysfs.h +++ b/datapath/brc_sysfs.h @@ -2,8 +2,8 @@ #define BRC_SYSFS_H 1 struct datapath; +struct net_bridge_port; -#include /* brc_sysfs_dp.c */ int brc_sysfs_add_dp(struct datapath *dp); int brc_sysfs_del_dp(struct datapath *dp); @@ -12,5 +12,14 @@ int brc_sysfs_del_dp(struct datapath *dp); int brc_sysfs_add_if(struct net_bridge_port *p); int brc_sysfs_del_if(struct net_bridge_port *p); +#include +#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) +#define SUPPORT_SYSFS 1 +#else +/* We only support sysfs on Linux 2.6.18 because that's the only place we + * really need it (on Xen, for brcompat) and it's a big pain to try to support + * multiple versions. */ +#endif + #endif /* brc_sysfs.h */ diff --git a/datapath/brc_sysfs_dp.c b/datapath/brc_sysfs_dp.c index 38702176..b5ac3b9c 100644 --- a/datapath/brc_sysfs_dp.c +++ b/datapath/brc_sysfs_dp.c @@ -20,7 +20,7 @@ #include "datapath.h" #include "dp_dev.h" -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) +#ifdef SUPPORT_SYSFS #define to_dev(obj) container_of(obj, struct device, kobj) /* Hack to attempt to build on more platforms. */ @@ -522,7 +522,7 @@ int brc_sysfs_del_dp(struct datapath *dp) return 0; } -#else +#else /* !SUPPORT_SYSFS */ int brc_sysfs_add_dp(struct datapath *dp) { return 0; } int brc_sysfs_del_dp(struct datapath *dp) { return 0; } int brc_sysfs_add_if(struct net_bridge_port *p) { return 0; } @@ -532,4 +532,4 @@ int brc_sysfs_del_if(struct net_bridge_port *p) kfree(p); return 0; } -#endif +#endif /* !SUPPORT_SYSFS */ diff --git a/datapath/brc_sysfs_if.c b/datapath/brc_sysfs_if.c index 9d269d16..12fa3778 100644 --- a/datapath/brc_sysfs_if.c +++ b/datapath/brc_sysfs_if.c @@ -1,6 +1,3 @@ -#include -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) - /* * Sysfs attributes of bridge ports for OpenVSwitch * @@ -13,10 +10,11 @@ #include #include #include - #include "brc_sysfs.h" #include "datapath.h" +#ifdef SUPPORT_SYSFS + struct brport_attribute { struct attribute attr; ssize_t (*show)(struct net_bridge_port *, char *); @@ -332,4 +330,4 @@ int brc_sysfs_del_if(struct net_bridge_port *p) return 0; } -#endif /* Only support 2.6.18 */ +#endif /* SUPPORT_SYSFS */ diff --git a/datapath/brcompat.c b/datapath/brcompat.c index a675d9e9..c9aa8904 100644 --- a/datapath/brcompat.c +++ b/datapath/brcompat.c @@ -470,7 +470,7 @@ int brc_add_dp(struct datapath *dp) { if (!try_module_get(THIS_MODULE)) return -ENODEV; -#if CONFIG_SYSFS +#ifdef SUPPORT_SYSFS brc_sysfs_add_dp(dp); #endif @@ -479,7 +479,7 @@ int brc_add_dp(struct datapath *dp) int brc_del_dp(struct datapath *dp) { -#if CONFIG_SYSFS +#ifdef SUPPORT_SYSFS brc_sysfs_del_dp(dp); #endif module_put(THIS_MODULE); @@ -516,7 +516,7 @@ __init brc_init(void) dp_del_dp_hook = brc_del_dp; /* Register hooks for interface adds and deletes */ -#if CONFIG_SYSFS +#ifdef SUPPORT_SYSFS dp_add_if_hook = brc_sysfs_add_if; dp_del_if_hook = brc_sysfs_del_if; #endif diff --git a/datapath/datapath.c b/datapath/datapath.c index 0fc4ad27..e3cc7d8c 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -449,7 +449,7 @@ int dp_del_port(struct net_bridge_port *p) { ASSERT_RTNL(); -#if CONFIG_SYSFS +#ifdef SUPPORT_SYSFS if ((p->port_no != ODPP_LOCAL) && dp_del_if_hook) sysfs_remove_link(&p->dp->ifobj, p->dev->name); #endif diff --git a/datapath/datapath.h b/datapath/datapath.h index 416821b3..1458d084 100644 --- a/datapath/datapath.h +++ b/datapath/datapath.h @@ -11,6 +11,7 @@ #include #include #include "flow.h" +#include "brc_sysfs.h" struct sk_buff; @@ -63,7 +64,9 @@ struct datapath { struct net_device *netdev; /* ofX network device. */ +#ifdef SUPPORT_SYSFS struct kobject ifobj; +#endif int drop_frags; @@ -91,7 +94,9 @@ struct net_bridge_port { u16 port_no; struct datapath *dp; struct net_device *dev; +#ifdef SUPPORT_SYSFS struct kobject kobj; +#endif #ifdef SUPPORT_SNAT spinlock_t lock; struct snat_conf *snat;