提交 df9890c3 编写于 作者: Y YOSHIFUJI Hideaki

[IPV6]: Fix sending extension headers before and including routing header.

Based on suggestion from Masahide Nakamura <nakam@linux-ipv6.org>.
Signed-off-by: NYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
上级 a3059893
...@@ -237,6 +237,8 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t ...@@ -237,6 +237,8 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t
int newtype, int newtype,
struct ipv6_opt_hdr __user *newopt, struct ipv6_opt_hdr __user *newopt,
int newoptlen); int newoptlen);
struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
struct ipv6_txoptions *opt);
extern int ip6_frag_nqueues; extern int ip6_frag_nqueues;
extern atomic_t ip6_frag_mem; extern atomic_t ip6_frag_mem;
......
...@@ -673,3 +673,22 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt, ...@@ -673,3 +673,22 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
return ERR_PTR(err); return ERR_PTR(err);
} }
struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
struct ipv6_txoptions *opt)
{
/*
* ignore the dest before srcrt unless srcrt is being included.
* --yoshfuji
*/
if (opt && opt->dst0opt && !opt->srcrt) {
if (opt_space != opt) {
memcpy(opt_space, opt, sizeof(*opt_space));
opt = opt_space;
}
opt->opt_nflen -= ipv6_optlen(opt->dst0opt);
opt->dst0opt = NULL;
}
return opt;
}
...@@ -225,20 +225,16 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space, ...@@ -225,20 +225,16 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space,
struct ip6_flowlabel * fl, struct ip6_flowlabel * fl,
struct ipv6_txoptions * fopt) struct ipv6_txoptions * fopt)
{ {
struct ipv6_txoptions * fl_opt = fl ? fl->opt : NULL; struct ipv6_txoptions * fl_opt = fl->opt;
if (fopt == NULL || fopt->opt_flen == 0) { if (fopt == NULL || fopt->opt_flen == 0)
if (!fl_opt || !fl_opt->dst0opt || fl_opt->srcrt)
return fl_opt; return fl_opt;
}
if (fl_opt != NULL) { if (fl_opt != NULL) {
opt_space->hopopt = fl_opt->hopopt; opt_space->hopopt = fl_opt->hopopt;
opt_space->dst0opt = fl_opt->srcrt ? fl_opt->dst0opt : NULL; opt_space->dst0opt = fl_opt->dst0opt;
opt_space->srcrt = fl_opt->srcrt; opt_space->srcrt = fl_opt->srcrt;
opt_space->opt_nflen = fl_opt->opt_nflen; opt_space->opt_nflen = fl_opt->opt_nflen;
if (fl_opt->dst0opt && !fl_opt->srcrt)
opt_space->opt_nflen -= ipv6_optlen(fl_opt->dst0opt);
} else { } else {
if (fopt->opt_nflen == 0) if (fopt->opt_nflen == 0)
return fopt; return fopt;
......
...@@ -756,7 +756,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -756,7 +756,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
} }
if (opt == NULL) if (opt == NULL)
opt = np->opt; opt = np->opt;
if (flowlabel)
opt = fl6_merge_options(&opt_space, flowlabel, opt); opt = fl6_merge_options(&opt_space, flowlabel, opt);
opt = ipv6_fixup_options(&opt_space, opt);
fl.proto = proto; fl.proto = proto;
rawv6_probe_proto_opt(&fl, msg); rawv6_probe_proto_opt(&fl, msg);
......
...@@ -778,7 +778,9 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -778,7 +778,9 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
} }
if (opt == NULL) if (opt == NULL)
opt = np->opt; opt = np->opt;
if (flowlabel)
opt = fl6_merge_options(&opt_space, flowlabel, opt); opt = fl6_merge_options(&opt_space, flowlabel, opt);
opt = ipv6_fixup_options(&opt_space, opt);
fl->proto = IPPROTO_UDP; fl->proto = IPPROTO_UDP;
ipv6_addr_copy(&fl->fl6_dst, daddr); ipv6_addr_copy(&fl->fl6_dst, daddr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册