diff options
-rw-r--r-- | include/net/ip.h | 3 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/include/net/ip.h b/include/net/ip.h index c1f192b8cd0e..0135f3823e66 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -56,6 +56,9 @@ struct ipcm_cookie { | |||
56 | int oif; | 56 | int oif; |
57 | struct ip_options_rcu *opt; | 57 | struct ip_options_rcu *opt; |
58 | __u8 tx_flags; | 58 | __u8 tx_flags; |
59 | __u8 ttl; | ||
60 | __s16 tos; | ||
61 | char priority; | ||
59 | }; | 62 | }; |
60 | 63 | ||
61 | #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb)) | 64 | #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb)) |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index d9c4f113d709..56e34457ac07 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -189,7 +189,7 @@ EXPORT_SYMBOL(ip_cmsg_recv); | |||
189 | 189 | ||
190 | int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc) | 190 | int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc) |
191 | { | 191 | { |
192 | int err; | 192 | int err, val; |
193 | struct cmsghdr *cmsg; | 193 | struct cmsghdr *cmsg; |
194 | 194 | ||
195 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { | 195 | for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { |
@@ -215,6 +215,24 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc) | |||
215 | ipc->addr = info->ipi_spec_dst.s_addr; | 215 | ipc->addr = info->ipi_spec_dst.s_addr; |
216 | break; | 216 | break; |
217 | } | 217 | } |
218 | case IP_TTL: | ||
219 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) | ||
220 | return -EINVAL; | ||
221 | val = *(int *)CMSG_DATA(cmsg); | ||
222 | if (val < 1 || val > 255) | ||
223 | return -EINVAL; | ||
224 | ipc->ttl = val; | ||
225 | break; | ||
226 | case IP_TOS: | ||
227 | if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) | ||
228 | return -EINVAL; | ||
229 | val = *(int *)CMSG_DATA(cmsg); | ||
230 | if (val < 0 || val > 255) | ||
231 | return -EINVAL; | ||
232 | ipc->tos = val; | ||
233 | ipc->priority = rt_tos2priority(ipc->tos); | ||
234 | break; | ||
235 | |||
218 | default: | 236 | default: |
219 | return -EINVAL; | 237 | return -EINVAL; |
220 | } | 238 | } |