From f727ba797853f3fc034b822392a1642067d9947e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 14 Mar 2009 17:22:09 -0700 Subject: [PATCH] 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. --- datapath/brc_sysfs.h | 7 ------- datapath/brc_sysfs_dp.c | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) 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 -- 2.30.2