aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorFrancesco Fusco <ffusco@redhat.com>2013-09-24 09:43:09 -0400
committerDavid S. Miller <davem@davemloft.net>2013-09-28 18:21:52 -0400
commitaa6615814533c634190019ee3a5b10490026d545 (patch)
tree08543d020bd7e2500046143440d58cd031f9754c /net/ipv4/udp.c
parentf02db315b8d888570cb0d4496cfbb7e4acb047cb (diff)
ipv4: processing ancillary IP_TOS or IP_TTL
If IP_TOS or IP_TTL are specified as ancillary data, then sendmsg() sends out packets with the specified TTL or TOS overriding the socket values specified with the traditional setsockopt(). The struct inet_cork stores the values of TOS, TTL and priority that are passed through the struct ipcm_cookie. If there are user-specified TOS (tos != -1) or TTL (ttl != 0) in the struct ipcm_cookie, these values are used to override the per-socket values. In case of TOS also the priority is changed accordingly. Two helper functions get_rttos and get_rtconn_flags are defined to take into account the presence of a user specified TOS value when computing RT_TOS and RT_CONN_FLAGS. Signed-off-by: Francesco Fusco <ffusco@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 74d2c95db57f..22462d947750 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -855,6 +855,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
855 855
856 ipc.opt = NULL; 856 ipc.opt = NULL;
857 ipc.tx_flags = 0; 857 ipc.tx_flags = 0;
858 ipc.ttl = 0;
859 ipc.tos = -1;
858 860
859 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag; 861 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
860 862
@@ -938,7 +940,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
938 faddr = ipc.opt->opt.faddr; 940 faddr = ipc.opt->opt.faddr;
939 connected = 0; 941 connected = 0;
940 } 942 }
941 tos = RT_TOS(inet->tos); 943 tos = get_rttos(&ipc, inet);
942 if (sock_flag(sk, SOCK_LOCALROUTE) || 944 if (sock_flag(sk, SOCK_LOCALROUTE) ||
943 (msg->msg_flags & MSG_DONTROUTE) || 945 (msg->msg_flags & MSG_DONTROUTE) ||
944 (ipc.opt && ipc.opt->opt.is_strictroute)) { 946 (ipc.opt && ipc.opt->opt.is_strictroute)) {