raw.c (db6da59cf27b5661ced03754ae0550f8914eda9e) | raw.c (e1d001fa5b477c4da46a29be1fcece91db7c7c6f) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * RAW sockets for IPv6 4 * Linux INET6 implementation 5 * 6 * Authors: 7 * Pedro Roque <roque@di.fc.ul.pt> 8 * --- 779 unchanged lines hidden (view full) --- 788 if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 789 return -EAFNOSUPPORT; 790 791 /* port is the proto value [0..255] carried in nexthdr */ 792 proto = ntohs(sin6->sin6_port); 793 794 if (!proto) 795 proto = inet->inet_num; | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * RAW sockets for IPv6 4 * Linux INET6 implementation 5 * 6 * Authors: 7 * Pedro Roque <roque@di.fc.ul.pt> 8 * --- 779 unchanged lines hidden (view full) --- 788 if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 789 return -EAFNOSUPPORT; 790 791 /* port is the proto value [0..255] carried in nexthdr */ 792 proto = ntohs(sin6->sin6_port); 793 794 if (!proto) 795 proto = inet->inet_num; |
796 else if (proto != inet->inet_num) | 796 else if (proto != inet->inet_num && 797 inet->inet_num != IPPROTO_RAW) |
797 return -EINVAL; 798 799 if (proto > 255) 800 return -EINVAL; 801 802 daddr = &sin6->sin6_addr; 803 if (np->sndflow) { 804 fl6.flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK; --- 307 unchanged lines hidden (view full) --- 1112 fallthrough; 1113 default: 1114 return ipv6_getsockopt(sk, level, optname, optval, optlen); 1115 } 1116 1117 return do_rawv6_getsockopt(sk, level, optname, optval, optlen); 1118} 1119 | 798 return -EINVAL; 799 800 if (proto > 255) 801 return -EINVAL; 802 803 daddr = &sin6->sin6_addr; 804 if (np->sndflow) { 805 fl6.flowlabel = sin6->sin6_flowinfo&IPV6_FLOWINFO_MASK; --- 307 unchanged lines hidden (view full) --- 1113 fallthrough; 1114 default: 1115 return ipv6_getsockopt(sk, level, optname, optval, optlen); 1116 } 1117 1118 return do_rawv6_getsockopt(sk, level, optname, optval, optlen); 1119} 1120 |
1120static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg) | 1121static int rawv6_ioctl(struct sock *sk, int cmd, int *karg) |
1121{ 1122 switch (cmd) { 1123 case SIOCOUTQ: { | 1122{ 1123 switch (cmd) { 1124 case SIOCOUTQ: { |
1124 int amount = sk_wmem_alloc_get(sk); 1125 1126 return put_user(amount, (int __user *)arg); | 1125 *karg = sk_wmem_alloc_get(sk); 1126 return 0; |
1127 } 1128 case SIOCINQ: { 1129 struct sk_buff *skb; | 1127 } 1128 case SIOCINQ: { 1129 struct sk_buff *skb; |
1130 int amount = 0; | |
1131 1132 spin_lock_bh(&sk->sk_receive_queue.lock); 1133 skb = skb_peek(&sk->sk_receive_queue); 1134 if (skb) | 1130 1131 spin_lock_bh(&sk->sk_receive_queue.lock); 1132 skb = skb_peek(&sk->sk_receive_queue); 1133 if (skb) |
1135 amount = skb->len; | 1134 *karg = skb->len; 1135 else 1136 *karg = 0; |
1136 spin_unlock_bh(&sk->sk_receive_queue.lock); | 1137 spin_unlock_bh(&sk->sk_receive_queue.lock); |
1137 return put_user(amount, (int __user *)arg); | 1138 return 0; |
1138 } 1139 1140 default: 1141#ifdef CONFIG_IPV6_MROUTE | 1139 } 1140 1141 default: 1142#ifdef CONFIG_IPV6_MROUTE |
1142 return ip6mr_ioctl(sk, cmd, (void __user *)arg); | 1143 return ip6mr_ioctl(sk, cmd, karg); |
1143#else 1144 return -ENOIOCTLCMD; 1145#endif 1146 } 1147} 1148 1149#ifdef CONFIG_COMPAT 1150static int compat_rawv6_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg) --- 170 unchanged lines hidden --- | 1144#else 1145 return -ENOIOCTLCMD; 1146#endif 1147 } 1148} 1149 1150#ifdef CONFIG_COMPAT 1151static int compat_rawv6_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg) --- 170 unchanged lines hidden --- |