From: Florian Westphal <fw@strlen.de>
To: Fernando Fernandez Mancera <ffmancera@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next v3 3/4] netfilter: synproxy: extract SYNPROXY infrastructure from {ipt,ip6t}_SYNPROXY
Date: Mon, 27 May 2019 23:28:16 +0200 [thread overview]
Message-ID: <20190527212816.2xs6isymbgp5mp2d@breakpoint.cc> (raw)
In-Reply-To: <20190524170106.2686-4-ffmancera@riseup.net>
Fernando Fernandez Mancera <ffmancera@riseup.net> wrote:
> +static void
> +synproxy_send_tcp_ipv6(struct net *net,
> + const struct sk_buff *skb, struct sk_buff *nskb,
> + struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo,
> + struct ipv6hdr *niph, struct tcphdr *nth,
> + unsigned int tcp_hdr_size)
> +{
> + struct dst_entry *dst;
> + struct flowi6 fl6;
> +
> + nth->check = ~tcp_v6_check(tcp_hdr_size, &niph->saddr, &niph->daddr, 0);
> + nskb->ip_summed = CHECKSUM_PARTIAL;
> + nskb->csum_start = (unsigned char *)nth - nskb->head;
> + nskb->csum_offset = offsetof(struct tcphdr, check);
> +
> + memset(&fl6, 0, sizeof(fl6));
> + fl6.flowi6_proto = IPPROTO_TCP;
> + fl6.saddr = niph->saddr;
> + fl6.daddr = niph->daddr;
> + fl6.fl6_sport = nth->source;
> + fl6.fl6_dport = nth->dest;
> + security_skb_classify_flow((struct sk_buff *)skb,
> + flowi6_to_flowi(&fl6));
> + dst = ip6_route_output(net, NULL, &fl6);
All good, BUT the above function call also pulls in ipv6.ko.
You can fold this patch to avoid it, it coverts it to use the
nf_ip6_route() wrapper which internally uses the v6ops pointer
for ip6_route_output if needed.
diff --git a/net/netfilter/nf_synproxy.c b/net/netfilter/nf_synproxy.c
--- a/net/netfilter/nf_synproxy.c
+++ b/net/netfilter/nf_synproxy.c
@@ -434,6 +434,7 @@ synproxy_send_tcp_ipv6(struct net *net,
{
struct dst_entry *dst;
struct flowi6 fl6;
+ int err;
nth->check = ~tcp_v6_check(tcp_hdr_size, &niph->saddr, &niph->daddr, 0);
nskb->ip_summed = CHECKSUM_PARTIAL;
@@ -448,11 +449,10 @@ synproxy_send_tcp_ipv6(struct net *net,
fl6.fl6_dport = nth->dest;
security_skb_classify_flow((struct sk_buff *)skb,
flowi6_to_flowi(&fl6));
- dst = ip6_route_output(net, NULL, &fl6);
- if (dst->error) {
- dst_release(dst);
+ err = nf_ip6_route(net, &dst, flowi6_to_flowi(&fl6), false);
+ if (err)
goto free_nskb;
- }
+
dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
if (IS_ERR(dst))
goto free_nskb;
next prev parent reply other threads:[~2019-05-27 21:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 17:01 [PATCH nf-next v3 0/4] Extract SYNPROXY infrastructure Fernando Fernandez Mancera
2019-05-24 17:01 ` [PATCH nf-next v3 1/4] netfilter: synproxy: add common uapi for " Fernando Fernandez Mancera
2019-05-24 17:01 ` [PATCH nf-next v3 2/4] netfilter: synproxy: remove module dependency on IPv6 SYNPROXY Fernando Fernandez Mancera
2019-05-27 21:26 ` Florian Westphal
2019-05-24 17:01 ` [PATCH nf-next v3 3/4] netfilter: synproxy: extract SYNPROXY infrastructure from {ipt,ip6t}_SYNPROXY Fernando Fernandez Mancera
2019-05-27 21:28 ` Florian Westphal [this message]
2019-05-24 17:01 ` [PATCH nf-next v3 4/4] netfilter: add NF_SYNPROXY symbol Fernando Fernandez Mancera
2019-05-27 20:05 ` Florian Westphal
2019-05-27 21:34 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190527212816.2xs6isymbgp5mp2d@breakpoint.cc \
--to=fw@strlen.de \
--cc=ffmancera@riseup.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox