Skip to content

Commit 13b52cd

Browse files
Brian Haleydavem330
authored andcommitted
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: Brian Haley <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 793b147 commit 13b52cd

File tree

9 files changed

+46
-12
lines changed

9 files changed

+46
-12
lines changed

include/net/ipv6.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ extern int ip6_append_data(struct sock *sk,
503503
struct ipv6_txoptions *opt,
504504
struct flowi *fl,
505505
struct rt6_info *rt,
506-
unsigned int flags);
506+
unsigned int flags,
507+
int dontfrag);
507508

508509
extern int ip6_push_pending_frames(struct sock *sk);
509510

include/net/transp_v6.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ extern int datagram_send_ctl(struct net *net,
4444
struct msghdr *msg,
4545
struct flowi *fl,
4646
struct ipv6_txoptions *opt,
47-
int *hlimit, int *tclass);
47+
int *hlimit, int *tclass,
48+
int *dontfrag);
4849

4950
#define LOOPBACK4_IPV6 cpu_to_be32(0x7f000006)
5051

net/ipv6/datagram.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
497497
int datagram_send_ctl(struct net *net,
498498
struct msghdr *msg, struct flowi *fl,
499499
struct ipv6_txoptions *opt,
500-
int *hlimit, int *tclass)
500+
int *hlimit, int *tclass, int *dontfrag)
501501
{
502502
struct in6_pktinfo *src_info;
503503
struct cmsghdr *cmsg;
@@ -735,6 +735,25 @@ int datagram_send_ctl(struct net *net,
735735
err = 0;
736736
*tclass = tc;
737737

738+
break;
739+
}
740+
741+
case IPV6_DONTFRAG:
742+
{
743+
int df;
744+
745+
err = -EINVAL;
746+
if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
747+
goto exit_f;
748+
}
749+
750+
df = *(int *)CMSG_DATA(cmsg);
751+
if (df < 0 || df > 1)
752+
goto exit_f;
753+
754+
err = 0;
755+
*dontfrag = df;
756+
738757
break;
739758
}
740759
default:

net/ipv6/icmp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
481481
len + sizeof(struct icmp6hdr),
482482
sizeof(struct icmp6hdr), hlimit,
483483
np->tclass, NULL, &fl, (struct rt6_info*)dst,
484-
MSG_DONTWAIT);
484+
MSG_DONTWAIT, np->dontfrag);
485485
if (err) {
486486
ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
487487
ip6_flush_pending_frames(sk);
@@ -561,7 +561,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
561561

562562
err = ip6_append_data(sk, icmpv6_getfrag, &msg, skb->len + sizeof(struct icmp6hdr),
563563
sizeof(struct icmp6hdr), hlimit, np->tclass, NULL, &fl,
564-
(struct rt6_info*)dst, MSG_DONTWAIT);
564+
(struct rt6_info*)dst, MSG_DONTWAIT,
565+
np->dontfrag);
565566

566567
if (err) {
567568
ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);

net/ipv6/ip6_flowlabel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
360360
msg.msg_control = (void*)(fl->opt+1);
361361
flowi.oif = 0;
362362

363-
err = datagram_send_ctl(net, &msg, &flowi, fl->opt, &junk, &junk);
363+
err = datagram_send_ctl(net, &msg, &flowi, fl->opt, &junk,
364+
&junk, &junk);
364365
if (err)
365366
goto done;
366367
err = -EINVAL;

net/ipv6/ip6_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
11051105
int offset, int len, int odd, struct sk_buff *skb),
11061106
void *from, int length, int transhdrlen,
11071107
int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi *fl,
1108-
struct rt6_info *rt, unsigned int flags)
1108+
struct rt6_info *rt, unsigned int flags, int dontfrag)
11091109
{
11101110
struct inet_sock *inet = inet_sk(sk);
11111111
struct ipv6_pinfo *np = inet6_sk(sk);

net/ipv6/ipv6_sockglue.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
458458
msg.msg_controllen = optlen;
459459
msg.msg_control = (void*)(opt+1);
460460

461-
retv = datagram_send_ctl(net, &msg, &fl, opt, &junk, &junk);
461+
retv = datagram_send_ctl(net, &msg, &fl, opt, &junk, &junk,
462+
&junk);
462463
if (retv)
463464
goto done;
464465
update:

net/ipv6/raw.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
733733
int addr_len = msg->msg_namelen;
734734
int hlimit = -1;
735735
int tclass = -1;
736+
int dontfrag = -1;
736737
u16 proto;
737738
int err;
738739

@@ -811,7 +812,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
811812
memset(opt, 0, sizeof(struct ipv6_txoptions));
812813
opt->tot_len = sizeof(struct ipv6_txoptions);
813814

814-
err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit, &tclass);
815+
err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit,
816+
&tclass, &dontfrag);
815817
if (err < 0) {
816818
fl6_sock_release(flowlabel);
817819
return err;
@@ -880,6 +882,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
880882
if (tclass < 0)
881883
tclass = np->tclass;
882884

885+
if (dontfrag < 0)
886+
dontfrag = np->dontfrag;
887+
883888
if (msg->msg_flags&MSG_CONFIRM)
884889
goto do_confirm;
885890

@@ -890,7 +895,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
890895
lock_sock(sk);
891896
err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov,
892897
len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst,
893-
msg->msg_flags);
898+
msg->msg_flags, dontfrag);
894899

895900
if (err)
896901
ip6_flush_pending_frames(sk);

net/ipv6/udp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
919919
int ulen = len;
920920
int hlimit = -1;
921921
int tclass = -1;
922+
int dontfrag = -1;
922923
int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
923924
int err;
924925
int connected = 0;
@@ -1049,7 +1050,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
10491050
memset(opt, 0, sizeof(struct ipv6_txoptions));
10501051
opt->tot_len = sizeof(*opt);
10511052

1052-
err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit, &tclass);
1053+
err = datagram_send_ctl(sock_net(sk), msg, &fl, opt, &hlimit,
1054+
&tclass, &dontfrag);
10531055
if (err < 0) {
10541056
fl6_sock_release(flowlabel);
10551057
return err;
@@ -1120,6 +1122,9 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
11201122
if (tclass < 0)
11211123
tclass = np->tclass;
11221124

1125+
if (dontfrag < 0)
1126+
dontfrag = np->dontfrag;
1127+
11231128
if (msg->msg_flags&MSG_CONFIRM)
11241129
goto do_confirm;
11251130
back_from_confirm:
@@ -1143,7 +1148,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
11431148
err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
11441149
sizeof(struct udphdr), hlimit, tclass, opt, &fl,
11451150
(struct rt6_info*)dst,
1146-
corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
1151+
corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags, dontfrag);
11471152
if (err)
11481153
udp_v6_flush_pending_frames(sk);
11491154
else if (!corkreq)

0 commit comments

Comments
 (0)