From: Ben Pfaff Date: Sun, 15 Mar 2009 00:22:09 +0000 (-0700) Subject: brcompat: Fix netdevice refcount in non-2.6.18 when sysfs is available. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f727ba797853f3fc034b822392a1642067d9947e;p=openvswitch brcompat: Fix netdevice refcount in non-2.6.18 when sysfs is available. When sysfs is enabled, brcompat is responsible for releasing the netdevice reference and freeing the net_bridge_port in brc_sysfs_del_if(). However, when we're not building against 2.6.18, it was stubbed out to a function that did nothing. --- diff --git a/datapath/brc_sysfs.h b/datapath/brc_sysfs.h index fa972b00..8a550e3c 100644 --- a/datapath/brc_sysfs.h +++ b/datapath/brc_sysfs.h @@ -4,7 +4,6 @@ struct datapath; #include -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) /* brc_sysfs_dp.c */ int brc_sysfs_add_dp(struct datapath *dp); int brc_sysfs_del_dp(struct datapath *dp); @@ -12,12 +11,6 @@ int brc_sysfs_del_dp(struct datapath *dp); /* brc_sysfs_if.c */ int brc_sysfs_add_if(struct net_bridge_port *p); int brc_sysfs_del_if(struct net_bridge_port *p); -#else -static inline int brc_sysfs_add_dp(struct datapath *dp) { return 0; } -static inline int brc_sysfs_del_dp(struct datapath *dp) { return 0; } -static inline int brc_sysfs_add_if(struct net_bridge_port *p) { return 0; } -static inline int brc_sysfs_del_if(struct net_bridge_port *p) { return 0; } -#endif #endif /* brc_sysfs.h */ diff --git a/datapath/brc_sysfs_dp.c b/datapath/brc_sysfs_dp.c index b1b27ed1..a1b3c8e3 100644 --- a/datapath/brc_sysfs_dp.c +++ b/datapath/brc_sysfs_dp.c @@ -1,5 +1,4 @@ #include -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) /* * Sysfs attributes of bridge for OpenFlow @@ -21,6 +20,7 @@ #include "datapath.h" #include "dp_dev.h" +#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) #define to_dev(obj) container_of(obj, struct device, kobj) /* Hack to attempt to build on more platforms. */ @@ -516,4 +516,14 @@ int brc_sysfs_del_dp(struct datapath *dp) return 0; } -#endif /* Only support 2.6.18 */ +#else +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; } +int brc_sysfs_del_if(struct net_bridge_port *p) +{ + dev_put(p->dev); + kfree(p); + return 0; +} +#endif