netfilter: nf_reject_ipv6: fix locally generated packet to local address
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v5 1/1 netfilter: nf_reject_ipv6: fix locally generated packet to local address
Fix reject expression in inet/ingress for locally generated IPv6 packets that are sent to a local address on ethX arrives through lo, really perform the similar handling as ip6_rcv_core().
Reported by sashiko.
Fixes 73a73d442f99 ("netfilter: nf_reject: initialize IPCB at inet ingress")
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v5: add helper function as suggested by Fernando.
net/ipv6/netfilter/nf_reject_ipv6.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/ipv6/netfilter/nf_reject_ipv6.c +14 -1
@@ -448,6 +448,19 @@ static bool reject6_csum_ok(struct sk_buff *skb, int hook)return nf_ip6_checksum (skb, hook, thoff, proto) ==0 ; } +static int nf_reject6_ingress_iff (const struct sk_buff *skb) +{ +const struct inet6_dev *idev; + +if (skb_valid_dst (skb)) { + idev =ip6_dst_idev (skb_dst (skb)); +if (idev) +return idev->dev->ifindex; + } + +return skb->dev->ifindex; +} +void nf_send_unreach6 (struct net *net,struct sk_buff *skb_in,unsigned char code,unsigned int hooknum) {
@@ -459,7 +472,7 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,if (hooknum ==NF_INET_INGRESS ) {memset (IP6CB (skb_in),0 ,sizeof (*IP6CB (skb_in))); -IP6CB (skb_in)->iif = skb_in->skb_iif; +IP6CB (skb_in)->iif =nf_reject6_ingress_iff (skb_in); }if (!skb_valid_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 )
Signature · 1 line
2.47.3
Quoted 9 lines · Pablo Neira Ayuso
Fix reject expression in inet/ingress for locally generated IPv6 packets that are sent to a local address on ethX arrives through lo, really perform the similar handling as
ip6_rcv_core().Reported by sashiko.
Fixes 73a73d442f99 ("netfilter: nf_reject: initialize IPCB at inet ingress")Signed-off-by Pablo Neira Ayuso <[email protected]>
Reviewed-by Fernando Fernandez Mancera <[email protected]>
Thanks Pablo!