Commit 13b52cd4 authored by Brian Haley's avatar Brian Haley Committed by David S. Miller

IPv6: Add dontfrag argument to relevant functions

Add dontfrag argument to relevant functions for
IPV6_DONTFRAG support, as well as allowing the value
to be passed-in via ancillary cmsg data.
Signed-off-by: default avatarBrian Haley <brian.haley@hp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 793b1473
...@@ -503,7 +503,8 @@ extern int ip6_append_data(struct sock *sk, ...@@ -503,7 +503,8 @@ extern int ip6_append_data(struct sock *sk,
struct ipv6_txoptions *opt, struct ipv6_txoptions *opt,
struct flowi *fl, struct flowi *fl,
struct rt6_info *rt, struct rt6_info *rt,
unsigned int flags); unsigned int flags,
int dontfrag);
extern int ip6_push_pending_frames(struct sock *sk); extern int ip6_push_pending_frames(struct sock *sk);
......
...@@ -44,7 +44,8 @@ extern int datagram_send_ctl(struct net *net, ...@@ -44,7 +44,8 @@ extern int datagram_send_ctl(struct net *net,
struct msghdr *msg, struct msghdr *msg,
struct flowi *fl, struct flowi *fl,
struct ipv6_txoptions *opt, struct ipv6_txoptions *opt,
int *hlimit, int *tclass); int *hlimit, int *tclass,
int *dontfrag);
#define LOOPBACK4_IPV6 cpu_to_be32(0x7f000006) #define LOOPBACK4_IPV6 cpu_to_be32(0x7f000006)
......
...@@ -497,7 +497,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) ...@@ -497,7 +497,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
int datagram_send_ctl(struct net *net, int datagram_send_ctl(struct net *net,
struct msghdr *msg, struct flowi *fl, struct msghdr *msg, struct flowi *fl,
struct ipv6_txoptions *opt, struct ipv6_txoptions *opt,
int *hlimit, int *tclass) int *hlimit, int *tclass, int *dontfrag)
{ {
struct in6_pktinfo *src_info; struct in6_pktinfo *src_info;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
...@@ -735,6 +735,25 @@ int datagram_send_ctl(struct net *net, ...@@ -735,6 +735,25 @@ int datagram_send_ctl(struct net *net,
err = 0; err = 0;
*tclass = tc; *tclass = tc;
break;
}
case IPV6_DONTFRAG:
{
int df;
err = -EINVAL;
if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
goto exit_f;
}
df = *(int *)CMSG_DATA(cmsg);
if (df < 0 || df > 1)
goto exit_f;
err = 0;
*dontfrag = df;
break; break;
} }
default: default:
......
...@@ -481,7 +481,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) ...@@ -481,7 +481,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
len + sizeof(struct icmp6hdr), len + sizeof(struct icmp6hdr),
sizeof(struct icmp6hdr), hlimit, sizeof(struct icmp6hdr), hlimit,
np->tclass, NULL, &fl, (struct rt6_info*)dst, np->tclass, NULL, &fl, (struct rt6_info*)dst,
MSG_DONTWAIT); MSG_DONTWAIT, np->dontfrag);
if (err) { if (err) {
ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS); ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
ip6_flush_pending_frames(sk); ip6_flush_pending_frames(sk);
...@@ -561,7 +561,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb) ...@@ -561,7 +561,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr), err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr),
sizeof(struct icmp6hdr), hlimit, np->tclass, NULL, &fl, sizeof(struct icmp6hdr), hlimit, np->tclass, NULL, &fl,
(struct rt6_info*)dst, MSG_DONTWAIT); (struct rt6_info*)dst, MSG_DONTWAIT,
np->dontfrag);
if (err) { if (err) {
ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS); ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
......
...@@ -360,7 +360,8 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval, ...@@ -360,7 +360,8 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
msg.msg_control = (void*)(fl->opt+1); msg.msg_control = (void*)(fl->opt+1);
flowi.oif = 0; flowi.oif = 0;
err = datagram_send_ctl(net, &msg, &flowi, fl->opt, &junk, &junk); err = datagram_send_ctl(net, &msg, &flowi, fl->opt, &junk,
&junk, &junk);
if (err) if (err)
goto done; goto done;
err = -EINVAL; err = -EINVAL;
......
...@@ -1105,7 +1105,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, ...@@ -1105,7 +1105,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
int offset, int len, int odd, struct sk_buff *skb), int offset, int len, int odd, struct sk_buff *skb),
void *from, int length, int transhdrlen, void *from, int length, int transhdrlen,
int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl, int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl,
struct rt6_info *rt, unsigned int flags) struct rt6_info *rt, unsigned int flags, int dontfrag)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
......
...@@ -458,7 +458,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -458,7 +458,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
msg.msg_controllen = optlen; msg.msg_controllen = optlen;
msg.msg_control = (void*)(opt+1); msg.msg_control = (void*)(opt+1);
retv = datagram_send_ctl(net, &msg, &fl, opt, &junk, &junk); retv = datagram_send_ctl(net, &msg, &fl, opt, &junk, &junk,
&junk);
if (retv) if (retv)
goto done; goto done;
update: update:
......
...@@ -733,6 +733,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -733,6 +733,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
int addr_len = msg->msg_namelen; int addr_len = msg->msg_namelen;
int hlimit = -1; int hlimit = -1;
int tclass = -1; int tclass = -1;
int dontfrag = -1;
u16 proto; u16 proto;
int err; int err;
...@@ -811,7 +812,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -811,7 +812,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
memset(opt, 0, sizeof(struct ipv6_txoptions)); memset(opt, 0, sizeof(struct ipv6_txoptions));
opt->tot_len = sizeof(struct ipv6_txoptions); opt->tot_len = sizeof(struct ipv6_txoptions);
err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit, &tclass); err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit,
&tclass, &dontfrag);
if (err < 0) { if (err < 0) {
fl6_sock_release(flowlabel); fl6_sock_release(flowlabel);
return err; return err;
...@@ -880,6 +882,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -880,6 +882,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (tclass < 0) if (tclass < 0)
tclass = np->tclass; tclass = np->tclass;
if (dontfrag < 0)
dontfrag = np->dontfrag;
if (msg->msg_flags&MSG_CONFIRM) if (msg->msg_flags&MSG_CONFIRM)
goto do_confirm; goto do_confirm;
...@@ -890,7 +895,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -890,7 +895,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
lock_sock(sk); lock_sock(sk);
err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov,
len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst, len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst,
msg->msg_flags); msg->msg_flags, dontfrag);
if (err) if (err)
ip6_flush_pending_frames(sk); ip6_flush_pending_frames(sk);
......
...@@ -919,6 +919,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -919,6 +919,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
int ulen = len; int ulen = len;
int hlimit = -1; int hlimit = -1;
int tclass = -1; int tclass = -1;
int dontfrag = -1;
int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
int err; int err;
int connected = 0; int connected = 0;
...@@ -1049,7 +1050,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1049,7 +1050,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
memset(opt, 0, sizeof(struct ipv6_txoptions)); memset(opt, 0, sizeof(struct ipv6_txoptions));
opt->tot_len = sizeof(*opt); opt->tot_len = sizeof(*opt);
err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit, &tclass); err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit,
&tclass, &dontfrag);
if (err < 0) { if (err < 0) {
fl6_sock_release(flowlabel); fl6_sock_release(flowlabel);
return err; return err;
...@@ -1120,6 +1122,9 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1120,6 +1122,9 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (tclass < 0) if (tclass < 0)
tclass = np->tclass; tclass = np->tclass;
if (dontfrag < 0)
dontfrag = np->dontfrag;
if (msg->msg_flags&MSG_CONFIRM) if (msg->msg_flags&MSG_CONFIRM)
goto do_confirm; goto do_confirm;
back_from_confirm: back_from_confirm:
...@@ -1143,7 +1148,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1143,7 +1148,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen, err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
sizeof(struct udphdr), hlimit, tclass, opt, &fl, sizeof(struct udphdr), hlimit, tclass, opt, &fl,
(struct rt6_info*)dst, (struct rt6_info*)dst,
corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags, dontfrag);
if (err) if (err)
udp_v6_flush_pending_frames(sk); udp_v6_flush_pending_frames(sk);
else if (!corkreq) else if (!corkreq)
......
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