Commit da678292 authored by Michał Mirosław's avatar Michał Mirosław Committed by David S. Miller

bridge: Simplify interface for ATM LANE

This patch changes FDB entry check for ATM LANE bridge integration.
There's no point in holding a FDB entry around SKB building.

br_fdb_get()/br_fdb_put() pair are changed into single br_fdb_test_addr()
hook that checks if the addr has FDB entry pointing to other port
to the one the request arrived on.

FDB entry refcounting is removed as it's not used anywhere else.
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 746e6ad2
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
/* Proxy LEC knows about bridging */ /* Proxy LEC knows about bridging */
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
#include <linux/if_bridge.h>
#include "../bridge/br_private.h" #include "../bridge/br_private.h"
static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 }; static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
...@@ -518,18 +517,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -518,18 +517,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
case l_should_bridge: case l_should_bridge:
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
{ {
struct net_bridge_fdb_entry *f;
pr_debug("%s: bridge zeppelin asks about %pM\n", pr_debug("%s: bridge zeppelin asks about %pM\n",
dev->name, mesg->content.proxy.mac_addr); dev->name, mesg->content.proxy.mac_addr);
if (br_fdb_get_hook == NULL || dev->br_port == NULL) if (br_fdb_test_addr_hook == NULL)
break; break;
f = br_fdb_get_hook(dev->br_port->br, if (br_fdb_test_addr_hook(dev,
mesg->content.proxy.mac_addr); mesg->content.proxy.mac_addr)) {
if (f != NULL && f->dst->dev != dev
&& f->dst->state == BR_STATE_FORWARDING) {
/* hit from bridge table, send LE_ARP_RESPONSE */ /* hit from bridge table, send LE_ARP_RESPONSE */
struct sk_buff *skb2; struct sk_buff *skb2;
struct sock *sk; struct sock *sk;
...@@ -540,10 +535,8 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -540,10 +535,8 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
skb2 = skb2 =
alloc_skb(sizeof(struct atmlec_msg), alloc_skb(sizeof(struct atmlec_msg),
GFP_ATOMIC); GFP_ATOMIC);
if (skb2 == NULL) { if (skb2 == NULL)
br_fdb_put_hook(f);
break; break;
}
skb2->len = sizeof(struct atmlec_msg); skb2->len = sizeof(struct atmlec_msg);
skb_copy_to_linear_data(skb2, mesg, skb_copy_to_linear_data(skb2, mesg,
sizeof(*mesg)); sizeof(*mesg));
...@@ -552,8 +545,6 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) ...@@ -552,8 +545,6 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
skb_queue_tail(&sk->sk_receive_queue, skb2); skb_queue_tail(&sk->sk_receive_queue, skb2);
sk->sk_data_ready(sk, skb2->len); sk->sk_data_ready(sk, skb2->len);
} }
if (f != NULL)
br_fdb_put_hook(f);
} }
#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
break; break;
......
...@@ -65,8 +65,9 @@ static int __init br_init(void) ...@@ -65,8 +65,9 @@ static int __init br_init(void)
brioctl_set(br_ioctl_deviceless_stub); brioctl_set(br_ioctl_deviceless_stub);
br_handle_frame_hook = br_handle_frame; br_handle_frame_hook = br_handle_frame;
br_fdb_get_hook = br_fdb_get; #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
br_fdb_put_hook = br_fdb_put; br_fdb_test_addr_hook = br_fdb_test_addr;
#endif
return 0; return 0;
err_out4: err_out4:
...@@ -95,8 +96,9 @@ static void __exit br_deinit(void) ...@@ -95,8 +96,9 @@ static void __exit br_deinit(void)
synchronize_net(); synchronize_net();
br_netfilter_fini(); br_netfilter_fini();
br_fdb_get_hook = NULL; #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
br_fdb_put_hook = NULL; br_fdb_test_addr_hook = NULL;
#endif
br_handle_frame_hook = NULL; br_handle_frame_hook = NULL;
br_fdb_fini(); br_fdb_fini();
......
...@@ -71,10 +71,17 @@ static inline int br_mac_hash(const unsigned char *mac) ...@@ -71,10 +71,17 @@ static inline int br_mac_hash(const unsigned char *mac)
return jhash_1word(key, fdb_salt) & (BR_HASH_SIZE - 1); return jhash_1word(key, fdb_salt) & (BR_HASH_SIZE - 1);
} }
static void fdb_rcu_free(struct rcu_head *head)
{
struct net_bridge_fdb_entry *ent
= container_of(head, struct net_bridge_fdb_entry, rcu);
kmem_cache_free(br_fdb_cache, ent);
}
static inline void fdb_delete(struct net_bridge_fdb_entry *f) static inline void fdb_delete(struct net_bridge_fdb_entry *f)
{ {
hlist_del_rcu(&f->hlist); hlist_del_rcu(&f->hlist);
br_fdb_put(f); call_rcu(&f->rcu, fdb_rcu_free);
} }
void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr) void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
...@@ -226,33 +233,26 @@ struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br, ...@@ -226,33 +233,26 @@ struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
return NULL; return NULL;
} }
/* Interface used by ATM hook that keeps a ref count */ #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br, /* Interface used by ATM LANE hook to test
unsigned char *addr) * if an addr is on some other bridge port */
int br_fdb_test_addr(struct net_device *dev, unsigned char *addr)
{ {
struct net_bridge_fdb_entry *fdb; struct net_bridge_fdb_entry *fdb;
int ret;
if (!dev->br_port)
return 0;
rcu_read_lock(); rcu_read_lock();
fdb = __br_fdb_get(br, addr); fdb = __br_fdb_get(dev->br_port->br, addr);
if (fdb && !atomic_inc_not_zero(&fdb->use_count)) ret = fdb && fdb->dst->dev != dev &&
fdb = NULL; fdb->dst->state == BR_STATE_FORWARDING;
rcu_read_unlock(); rcu_read_unlock();
return fdb;
}
static void fdb_rcu_free(struct rcu_head *head)
{
struct net_bridge_fdb_entry *ent
= container_of(head, struct net_bridge_fdb_entry, rcu);
kmem_cache_free(br_fdb_cache, ent);
}
/* Set entry up for deletion with RCU */ return ret;
void br_fdb_put(struct net_bridge_fdb_entry *ent)
{
if (atomic_dec_and_test(&ent->use_count))
call_rcu(&ent->rcu, fdb_rcu_free);
} }
#endif /* CONFIG_ATM_LANE */
/* /*
* Fill buffer with forwarding table records in * Fill buffer with forwarding table records in
...@@ -326,7 +326,6 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head, ...@@ -326,7 +326,6 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head,
fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC); fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);
if (fdb) { if (fdb) {
memcpy(fdb->addr.addr, addr, ETH_ALEN); memcpy(fdb->addr.addr, addr, ETH_ALEN);
atomic_set(&fdb->use_count, 1);
hlist_add_head_rcu(&fdb->hlist, head); hlist_add_head_rcu(&fdb->hlist, head);
fdb->dst = source; fdb->dst = source;
......
...@@ -51,7 +51,6 @@ struct net_bridge_fdb_entry ...@@ -51,7 +51,6 @@ struct net_bridge_fdb_entry
struct net_bridge_port *dst; struct net_bridge_port *dst;
struct rcu_head rcu; struct rcu_head rcu;
atomic_t use_count;
unsigned long ageing_timer; unsigned long ageing_timer;
mac_addr addr; mac_addr addr;
unsigned char is_local; unsigned char is_local;
...@@ -154,9 +153,7 @@ extern void br_fdb_delete_by_port(struct net_bridge *br, ...@@ -154,9 +153,7 @@ extern void br_fdb_delete_by_port(struct net_bridge *br,
const struct net_bridge_port *p, int do_all); const struct net_bridge_port *p, int do_all);
extern struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br, extern struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
const unsigned char *addr); const unsigned char *addr);
extern struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br, extern int br_fdb_test_addr(struct net_device *dev, unsigned char *addr);
unsigned char *addr);
extern void br_fdb_put(struct net_bridge_fdb_entry *ent);
extern int br_fdb_fillbuf(struct net_bridge *br, void *buf, extern int br_fdb_fillbuf(struct net_bridge *br, void *buf,
unsigned long count, unsigned long off); unsigned long count, unsigned long off);
extern int br_fdb_insert(struct net_bridge *br, extern int br_fdb_insert(struct net_bridge *br,
...@@ -242,10 +239,9 @@ extern void br_stp_port_timer_init(struct net_bridge_port *p); ...@@ -242,10 +239,9 @@ extern void br_stp_port_timer_init(struct net_bridge_port *p);
extern unsigned long br_timer_value(const struct timer_list *timer); extern unsigned long br_timer_value(const struct timer_list *timer);
/* br.c */ /* br.c */
extern struct net_bridge_fdb_entry *(*br_fdb_get_hook)(struct net_bridge *br, #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
unsigned char *addr); extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr);
extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent); #endif
/* br_netlink.c */ /* br_netlink.c */
extern int br_netlink_init(void); extern int br_netlink_init(void);
......
...@@ -2071,11 +2071,13 @@ static inline int deliver_skb(struct sk_buff *skb, ...@@ -2071,11 +2071,13 @@ static inline int deliver_skb(struct sk_buff *skb,
} }
#if defined(CONFIG_BRIDGE) || defined (CONFIG_BRIDGE_MODULE) #if defined(CONFIG_BRIDGE) || defined (CONFIG_BRIDGE_MODULE)
/* These hooks defined here for ATM */
struct net_bridge; #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
struct net_bridge_fdb_entry *(*br_fdb_get_hook)(struct net_bridge *br, /* This hook is defined here for ATM LANE */
unsigned char *addr); int (*br_fdb_test_addr_hook)(struct net_device *dev,
void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent) __read_mostly; unsigned char *addr) __read_mostly;
EXPORT_SYMBOL(br_fdb_test_addr_hook);
#endif
/* /*
* If bridge module is loaded call bridging hook. * If bridge module is loaded call bridging hook.
...@@ -2083,6 +2085,8 @@ void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent) __read_mostly; ...@@ -2083,6 +2085,8 @@ void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent) __read_mostly;
*/ */
struct sk_buff *(*br_handle_frame_hook)(struct net_bridge_port *p, struct sk_buff *(*br_handle_frame_hook)(struct net_bridge_port *p,
struct sk_buff *skb) __read_mostly; struct sk_buff *skb) __read_mostly;
EXPORT_SYMBOL(br_handle_frame_hook);
static inline struct sk_buff *handle_bridge(struct sk_buff *skb, static inline struct sk_buff *handle_bridge(struct sk_buff *skb,
struct packet_type **pt_prev, int *ret, struct packet_type **pt_prev, int *ret,
struct net_device *orig_dev) struct net_device *orig_dev)
...@@ -5665,12 +5669,6 @@ EXPORT_SYMBOL(net_enable_timestamp); ...@@ -5665,12 +5669,6 @@ EXPORT_SYMBOL(net_enable_timestamp);
EXPORT_SYMBOL(net_disable_timestamp); EXPORT_SYMBOL(net_disable_timestamp);
EXPORT_SYMBOL(dev_get_flags); EXPORT_SYMBOL(dev_get_flags);
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
EXPORT_SYMBOL(br_handle_frame_hook);
EXPORT_SYMBOL(br_fdb_get_hook);
EXPORT_SYMBOL(br_fdb_put_hook);
#endif
EXPORT_SYMBOL(dev_load); EXPORT_SYMBOL(dev_load);
EXPORT_PER_CPU_SYMBOL(softnet_data); EXPORT_PER_CPU_SYMBOL(softnet_data);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment