netfilter: ebtables: make broute table work again
Subsystems (4)
Florian Westphal
maintainerPATCH RESEND 1/1 netfilter: ebtables: make broute table work again
broute table init hook sets up the "br_should_route_hook" pointer, which then gets called from br_input.
commit a386f99025f13b32502fe5dedf223c20d7283826 (bridge: add proper RCU annotation to should_route_hook) introduced a typedef, and then changed this to:
br_should_route_hook_t *rhook;
[..]
rhook = rcu_dereference(br_should_route_hook);
if (*rhook(skb))
problem is that "br_should_route_hook" contains the address of the function, so calling *rhook() results in kernel panic.
Can't simply use "if (rhook(skb)", because br_should_route_hook_t *rhook is not a function.
---
Eric, does this patch look sane to you?
Pablo, only the if_bridge.h change is needed.
If you do not like the br_input.c change, feel
free to remove it when applying.
Thanks!
include/linux/if_bridge.h +1 -1
@@ -103,7 +103,7 @@ struct __fdb_entry {extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *)); -typedef int (*br_should_route_hook_t )(struct sk_buff *skb); +typedef int br_should_route_hook_t (struct sk_buff *skb);extern br_should_route_hook_t __rcu *br_should_route_hook;#endif
net/bridge/br_input.c +1 -1
@@ -178,7 +178,7 @@ forward:case BR_STATE_FORWARDING : rhook =rcu_dereference (br_should_route_hook);if (rhook) { -if ((*rhook)(skb)) +if (rhook (skb))return skb; dest =eth_hdr (skb)->h_dest; }
Signature · 1 line
1.7.2.2
Quoted 34 lines · Florian Westphal
broute table init hook sets up the "
br_should_route_hook" pointer, which then gets called frombr_input.commit
a386f99025f13b32502fe5dedf223c20d7283826(bridge: add proper RCU annotation toshould_route_hook) introduced a typedef, and then changed this to:
br_should_route_hook_t*rhook;
[..]
rhook =rcu_dereference(br_should_route_hook);
if (*rhook(skb))problem is that "
br_should_route_hook" contains the address of the function, so calling*rhook()results in kernel panic.Can't simply use "if (rhook(skb)", because
br_should_route_hook_t*rhook is not a function.Cc Eric Dumazet <[email protected]>Signed-off-by Florian Westphal <[email protected]>---
Eric, does this patch look sane to you?Pablo, only the
if_bridge.hchange is needed.
If you do not like thebr_input.cchange, feel
free to remove it when applying.Thanks!
include/linux/if_bridge.h +0
-0
include/linux/if_bridge.h struct __fdb_entry { · line 107
Quoted 6 lines
include/linux/if_bridge.h +1
-1@@ -103,7 +103,7 @@ struct __fdb_entry {extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *)); -typedef int (*br_should_route_hook_t )(struct sk_buff *skb); +typedef int br_should_route_hook_t (struct sk_buff *skb);extern br_should_route_hook_t __rcu *br_should_route_hook;
Hi Florian
It seems I was on crack at that time, but I remember having problem with sparse on :
net/bridge/netfilter/ebtable_broute.c:90:2: error: cannot dereference this type
Lets ignore sparse for the time being...
Please dont change the invocation of (*rhook) to make clear its an indirect call. Both syntaxes are valid in C.
You also can remove one un needed cast now.
Soemthing like :
include/linux/if_bridge.h +1 -1
@@ -103,7 +103,7 @@ struct __fdb_entry {extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *)); -typedef int (*br_should_route_hook_t )(struct sk_buff *skb); +typedef int br_should_route_hook_t (struct sk_buff *skb);extern br_should_route_hook_t __rcu *br_should_route_hook;#endif
net/bridge/netfilter/ebtable_broute.c +1 -2
@@ -87,8 +87,7 @@ static int __init ebtable_broute_init(void)if (ret <0 )return ret;/* see br_input.c */ -rcu_assign_pointer (br_should_route_hook, - (br_should_route_hook_t *)ebt_broute); +rcu_assign_pointer (br_should_route_hook, ebt_broute);return 0 ; }
Thanks !
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Florian Westphal
maintainerQuoted 17 lines · Eric Dumazet
include/linux/if_bridge.h struct __fdb_entry { · line 107
Quoted 11 lines
include/linux/if_bridge.h +1
-1@@ -103,7 +103,7 @@ struct __fdb_entry {extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *)); -typedef int (*br_should_route_hook_t )(struct sk_buff *skb); +typedef int br_should_route_hook_t (struct sk_buff *skb);extern br_should_route_hook_t __rcu *br_should_route_hook;Hi Florian
It seems I was on crack at that time, but I remember having problem with sparse on :
Quoted 6 lines
net/bridge/netfilter/ebtable_broute.c:90:2: error: cannot dereference this typeLets ignore sparse for the time being...
Please dont change the invocation of (*rhook) to make clear its an indirect call. Both syntaxes are valid in C.
okay.
Quoted 1 line
You also can remove one un needed cast now.
You're right about the cast, but removing it causes the sparse splat you quoted above...
I'll resend a v2 containing the change below only.
Thanks for looking at this,
Florian
Quoted 7 lines
include/linux/if_bridge.h +1
-1extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *)); -typedef int (*br_should_route_hook_t )(struct sk_buff *skb); +typedef int br_should_route_hook_t (struct sk_buff *skb);extern br_should_route_hook_t __rcu *br_should_route_hook;