mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-01 12:04:08 +00:00
bridge: ebtables: don't crash when using dnat target in output chains
xt_in() returns NULL in the output hook, skip the pkt_type change for
that case, redirection only makes sense in broute/prerouting hooks.
Reported-by: Tom Yan <tom.ty89@gmail.com>
Cc: Linus Lüssing <linus.luessing@c0d3.blue>
Fixes: cf3cb246e2
("bridge: ebtables: fix reception of frames DNAT-ed to bridge device/port")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
9fedd894b4
commit
b23c0742c2
1 changed files with 15 additions and 4 deletions
|
@ -20,7 +20,6 @@ static unsigned int
|
||||||
ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
||||||
{
|
{
|
||||||
const struct ebt_nat_info *info = par->targinfo;
|
const struct ebt_nat_info *info = par->targinfo;
|
||||||
struct net_device *dev;
|
|
||||||
|
|
||||||
if (skb_ensure_writable(skb, ETH_ALEN))
|
if (skb_ensure_writable(skb, ETH_ALEN))
|
||||||
return EBT_DROP;
|
return EBT_DROP;
|
||||||
|
@ -33,10 +32,22 @@ ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
||||||
else
|
else
|
||||||
skb->pkt_type = PACKET_MULTICAST;
|
skb->pkt_type = PACKET_MULTICAST;
|
||||||
} else {
|
} else {
|
||||||
if (xt_hooknum(par) != NF_BR_BROUTING)
|
const struct net_device *dev;
|
||||||
dev = br_port_get_rcu(xt_in(par))->br->dev;
|
|
||||||
else
|
switch (xt_hooknum(par)) {
|
||||||
|
case NF_BR_BROUTING:
|
||||||
dev = xt_in(par);
|
dev = xt_in(par);
|
||||||
|
break;
|
||||||
|
case NF_BR_PRE_ROUTING:
|
||||||
|
dev = br_port_get_rcu(xt_in(par))->br->dev;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dev = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev) /* NF_BR_LOCAL_OUT */
|
||||||
|
return info->target;
|
||||||
|
|
||||||
if (ether_addr_equal(info->mac, dev->dev_addr))
|
if (ether_addr_equal(info->mac, dev->dev_addr))
|
||||||
skb->pkt_type = PACKET_HOST;
|
skb->pkt_type = PACKET_HOST;
|
||||||
|
|
Loading…
Add table
Reference in a new issue