Skip to content

Commit 4e70ba1

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: nft_fwd_netdev: check ttl/hl before forwarding
[ Upstream commit 1dfd95b ] Drop packets if their ttl/hl is too small for forwarding. Fixes: d32de98 ("netfilter: nft_fwd_netdev: allow to forward packets via neighbour layer") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 439117c commit 4e70ba1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

net/netfilter/nft_fwd_netdev.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
116116
goto out;
117117
}
118118
iph = ip_hdr(skb);
119+
if (iph->ttl <= 1) {
120+
verdict = NF_DROP;
121+
goto out;
122+
}
123+
119124
ip_decrease_ttl(iph);
120125
neigh_table = NEIGH_ARP_TABLE;
121126
break;
@@ -132,6 +137,11 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
132137
goto out;
133138
}
134139
ip6h = ipv6_hdr(skb);
140+
if (ip6h->hop_limit <= 1) {
141+
verdict = NF_DROP;
142+
goto out;
143+
}
144+
135145
ip6h->hop_limit--;
136146
neigh_table = NEIGH_ND_TABLE;
137147
break;

0 commit comments

Comments
 (0)