diff mbox series

[nf] netfilter: nf_queue: enqueue skbs with NULL dst

Message ID 20191202184259.30416-1-marco.oliverio@tanaza.com
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series [nf] netfilter: nf_queue: enqueue skbs with NULL dst | expand

Commit Message

Marco Oliverio Dec. 2, 2019, 6:42 p.m. UTC
Bridge packets that are forwarded have skb->dst == NULL and get
dropped by the check introduced by
b60a77386b1d4868f72f6353d35dabe5fbe981f2 (net: make skb_dst_force
return true when dst is refcounted).

To fix this we check skb_dst() before skb_dst_force(), so we don't
drop skb packet with dst == NULL. This holds also for skb at the
PRE_ROUTING hook so we remove the second check.

Fixes: b60a773 ("net: make skb_dst_forcereturn true when dst is refcounted")

Signed-off-by: Marco Oliverio <marco.oliverio@tanaza.com>
Signed-off-by: Rocco Folino <rocco.folino@tanaza.com>
---
 net/netfilter/nf_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matteo Croce Dec. 2, 2019, 9:51 p.m. UTC | #1
On Mon, Dec 2, 2019 at 7:43 PM Marco Oliverio <marco.oliverio@tanaza.com> wrote:
>
> Bridge packets that are forwarded have skb->dst == NULL and get
> dropped by the check introduced by
> b60a77386b1d4868f72f6353d35dabe5fbe981f2 (net: make skb_dst_force
> return true when dst is refcounted).
>
> To fix this we check skb_dst() before skb_dst_force(), so we don't
> drop skb packet with dst == NULL. This holds also for skb at the
> PRE_ROUTING hook so we remove the second check.
>
> Fixes: b60a773 ("net: make skb_dst_forcereturn true when dst is refcounted")
>
> Signed-off-by: Marco Oliverio <marco.oliverio@tanaza.com>
> Signed-off-by: Rocco Folino <rocco.folino@tanaza.com>

Tested-by: Matteo Croce <mcroce@redhat.com>
diff mbox series

Patch

diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index a2b58de82600..f8f52ff99cfb 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -189,7 +189,7 @@  static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
 		goto err;
 	}
 
-	if (!skb_dst_force(skb) && state->hook != NF_INET_PRE_ROUTING) {
+	if (skb_dst(skb) && !skb_dst_force(skb)) {
 		status = -ENETDOWN;
 		goto err;
 	}