Commit d656b2ea authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jakub Kicinski

ipv6: clean up cork setup/release

Clean up ip6_setup_cork() and ip6_cork_release() adding a local variable
for v6_cork->opt. It's a preparation patch for further changes.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b60d4e58
...@@ -1354,7 +1354,7 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork, ...@@ -1354,7 +1354,7 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
{ {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
unsigned int mtu; unsigned int mtu;
struct ipv6_txoptions *opt = ipc6->opt; struct ipv6_txoptions *nopt, *opt = ipc6->opt;
/* /*
* setup for corking * setup for corking
...@@ -1363,32 +1363,28 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork, ...@@ -1363,32 +1363,28 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
if (WARN_ON(v6_cork->opt)) if (WARN_ON(v6_cork->opt))
return -EINVAL; return -EINVAL;
v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation); nopt = v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
if (unlikely(!v6_cork->opt)) if (unlikely(!nopt))
return -ENOBUFS; return -ENOBUFS;
v6_cork->opt->tot_len = sizeof(*opt); nopt->tot_len = sizeof(*opt);
v6_cork->opt->opt_flen = opt->opt_flen; nopt->opt_flen = opt->opt_flen;
v6_cork->opt->opt_nflen = opt->opt_nflen; nopt->opt_nflen = opt->opt_nflen;
v6_cork->opt->dst0opt = ip6_opt_dup(opt->dst0opt, nopt->dst0opt = ip6_opt_dup(opt->dst0opt, sk->sk_allocation);
sk->sk_allocation); if (opt->dst0opt && !nopt->dst0opt)
if (opt->dst0opt && !v6_cork->opt->dst0opt)
return -ENOBUFS; return -ENOBUFS;
v6_cork->opt->dst1opt = ip6_opt_dup(opt->dst1opt, nopt->dst1opt = ip6_opt_dup(opt->dst1opt, sk->sk_allocation);
sk->sk_allocation); if (opt->dst1opt && !nopt->dst1opt)
if (opt->dst1opt && !v6_cork->opt->dst1opt)
return -ENOBUFS; return -ENOBUFS;
v6_cork->opt->hopopt = ip6_opt_dup(opt->hopopt, nopt->hopopt = ip6_opt_dup(opt->hopopt, sk->sk_allocation);
sk->sk_allocation); if (opt->hopopt && !nopt->hopopt)
if (opt->hopopt && !v6_cork->opt->hopopt)
return -ENOBUFS; return -ENOBUFS;
v6_cork->opt->srcrt = ip6_rthdr_dup(opt->srcrt, nopt->srcrt = ip6_rthdr_dup(opt->srcrt, sk->sk_allocation);
sk->sk_allocation); if (opt->srcrt && !nopt->srcrt)
if (opt->srcrt && !v6_cork->opt->srcrt)
return -ENOBUFS; return -ENOBUFS;
/* need source address above miyazawa*/ /* need source address above miyazawa*/
...@@ -1820,11 +1816,13 @@ static void ip6_cork_release(struct inet_cork_full *cork, ...@@ -1820,11 +1816,13 @@ static void ip6_cork_release(struct inet_cork_full *cork,
struct inet6_cork *v6_cork) struct inet6_cork *v6_cork)
{ {
if (v6_cork->opt) { if (v6_cork->opt) {
kfree(v6_cork->opt->dst0opt); struct ipv6_txoptions *opt = v6_cork->opt;
kfree(v6_cork->opt->dst1opt);
kfree(v6_cork->opt->hopopt); kfree(opt->dst0opt);
kfree(v6_cork->opt->srcrt); kfree(opt->dst1opt);
kfree(v6_cork->opt); kfree(opt->hopopt);
kfree(opt->srcrt);
kfree(opt);
v6_cork->opt = NULL; v6_cork->opt = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment