Skip to content

Commit bf83922

Browse files
mtardyKernel Patches Daemon
authored andcommitted
net: move netfilter nf_reject6_fill_skb_dst to core ipv6
Move and rename nf_reject6_fill_skb_dst from ipv6/netfilter/nf_reject_ipv6 to ip6_route_reply_fetch_dst in ipv6/route.c so that it can be reused in the following patches by BPF kfuncs. Netfilter uses nf_ip6_route that is almost a transparent wrapper around ip6_route_outputy so this patch inlines it. Signed-off-by: Mahe Tardy <[email protected]>
1 parent 9d89577 commit bf83922

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

include/net/ip6_route.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ static inline struct dst_entry *ip6_route_output(struct net *net,
9393
return ip6_route_output_flags(net, sk, fl6, 0);
9494
}
9595

96+
int ip6_route_reply_fetch_dst(struct sk_buff *skb);
97+
9698
/* Only conditionally release dst if flags indicates
9799
* !RT6_LOOKUP_F_DST_NOREF or dst is in uncached_list.
98100
*/

net/ipv6/netfilter/nf_reject_ipv6.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,6 @@ void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
250250
}
251251
EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_put);
252252

253-
static int nf_reject6_fill_skb_dst(struct sk_buff *skb_in)
254-
{
255-
struct dst_entry *dst = NULL;
256-
struct flowi fl;
257-
258-
memset(&fl, 0, sizeof(struct flowi));
259-
fl.u.ip6.daddr = ipv6_hdr(skb_in)->saddr;
260-
nf_ip6_route(dev_net(skb_in->dev), &dst, &fl, false);
261-
if (!dst)
262-
return -1;
263-
264-
skb_dst_set(skb_in, dst);
265-
return 0;
266-
}
267-
268253
void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
269254
int hook)
270255
{
@@ -398,7 +383,7 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,
398383
skb_in->dev = net->loopback_dev;
399384

400385
if ((hooknum == NF_INET_PRE_ROUTING || hooknum == NF_INET_INGRESS) &&
401-
nf_reject6_fill_skb_dst(skb_in) < 0)
386+
ip6_route_reply_fetch_dst(skb_in) < 0)
402387
return;
403388

404389
icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0);

net/ipv6/route.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,6 +2705,24 @@ struct dst_entry *ip6_route_output_flags(struct net *net,
27052705
}
27062706
EXPORT_SYMBOL_GPL(ip6_route_output_flags);
27072707

2708+
int ip6_route_reply_fetch_dst(struct sk_buff *skb)
2709+
{
2710+
struct dst_entry *result;
2711+
struct flowi6 fl = {
2712+
.daddr = ipv6_hdr(skb)->saddr
2713+
};
2714+
int err;
2715+
2716+
result = ip6_route_output(dev_net(skb->dev), NULL, &fl);
2717+
err = result->error;
2718+
if (err)
2719+
dst_release(result);
2720+
else
2721+
skb_dst_set(skb, result);
2722+
return err;
2723+
}
2724+
EXPORT_SYMBOL_GPL(ip6_route_reply_fetch_dst);
2725+
27082726
struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig)
27092727
{
27102728
struct rt6_info *rt, *ort = dst_rt6_info(dst_orig);

0 commit comments

Comments
 (0)