aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2012-06-12 14:56:08 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2012-06-12 14:56:08 +0000
commitf584d74b4d995497ac2b23f0aabfd6bd0d5e0441 (patch)
tree88541982875708605e986966593f3e877b339302 /sys
parent0ca5e953e74b23ebcdc7ea67bd54d390dbb39382 (diff)
downloadsrc-f584d74b4d995497ac2b23f0aabfd6bd0d5e0441.tar.gz
src-f584d74b4d995497ac2b23f0aabfd6bd0d5e0441.zip
Add a cmsg of type IP_TOS for UDP/IPv4 sockets to specify the TOS byte.
MFC after: 3 days
Notes
Notes: svn path=/head/; revision=236961
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/udp_usrreq.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index d3e7acaa0c65..9f947a69367f 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -956,6 +956,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
int ipflags;
u_short fport, lport;
int unlock_udbinfo;
+ u_char tos;
/*
* udp_output() may need to temporarily bind or connect the current
@@ -972,6 +973,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
src.sin_family = 0;
INP_RLOCK(inp);
+ tos = inp->inp_ip_tos;
if (control != NULL) {
/*
* XXX: Currently, we assume all the optional information is
@@ -1010,6 +1012,14 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
*(struct in_addr *)CMSG_DATA(cm);
break;
+ case IP_TOS:
+ if (cm->cmsg_len != CMSG_LEN(sizeof(u_char))) {
+ error = EINVAL;
+ break;
+ }
+ tos = *(u_char *)CMSG_DATA(cm);
+ break;
+
default:
error = ENOPROTOOPT;
break;
@@ -1225,7 +1235,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
ui->ui_sum = 0;
((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
- ((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
+ ((struct ip *)ui)->ip_tos = tos; /* XXX */
UDPSTAT_INC(udps_opackets);
if (unlock_udbinfo == UH_WLOCKED)