|
@@ -189,7 +189,7 @@ EXPORT_SYMBOL(ip_cmsg_recv);
|
|
|
|
|
|
int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc)
|
|
|
{
|
|
|
- int err;
|
|
|
+ int err, val;
|
|
|
struct cmsghdr *cmsg;
|
|
|
|
|
|
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)
|
|
|
ipc->addr = info->ipi_spec_dst.s_addr;
|
|
|
break;
|
|
|
}
|
|
|
+ case IP_TTL:
|
|
|
+ if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)))
|
|
|
+ return -EINVAL;
|
|
|
+ val = *(int *)CMSG_DATA(cmsg);
|
|
|
+ if (val < 1 || val > 255)
|
|
|
+ return -EINVAL;
|
|
|
+ ipc->ttl = val;
|
|
|
+ break;
|
|
|
+ case IP_TOS:
|
|
|
+ if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)))
|
|
|
+ return -EINVAL;
|
|
|
+ val = *(int *)CMSG_DATA(cmsg);
|
|
|
+ if (val < 0 || val > 255)
|
|
|
+ return -EINVAL;
|
|
|
+ ipc->tos = val;
|
|
|
+ ipc->priority = rt_tos2priority(ipc->tos);
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
return -EINVAL;
|
|
|
}
|