Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: drop capability from protocol definitions

struct can_proto had a capability field which wasn't ever used. It is
dropped entirely.

struct inet_protosw had a capability field which can be more clearly
expressed in the code by just checking if sock->type = SOCK_RAW.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Paris and committed by
David S. Miller
13f18aa0 89794a6f

+2 -29
-2
include/linux/can/core.h
··· 32 32 * struct can_proto - CAN protocol structure 33 33 * @type: type argument in socket() syscall, e.g. SOCK_DGRAM. 34 34 * @protocol: protocol number in socket() syscall. 35 - * @capability: capability needed to open the socket, or -1 for no restriction. 36 35 * @ops: pointer to struct proto_ops for sock->ops. 37 36 * @prot: pointer to struct proto structure. 38 37 */ 39 38 struct can_proto { 40 39 int type; 41 40 int protocol; 42 - int capability; 43 41 struct proto_ops *ops; 44 42 struct proto *prot; 45 43 };
-4
include/net/protocol.h
··· 82 82 struct proto *prot; 83 83 const struct proto_ops *ops; 84 84 85 - int capability; /* Which (if any) capability do 86 - * we need to use this socket 87 - * interface? 88 - */ 89 85 char no_check; /* checksum on rcv/xmit/none? */ 90 86 unsigned char flags; /* See INET_PROTOSW_* below. */ 91 87 };
-5
net/can/af_can.c
··· 160 160 goto errout; 161 161 } 162 162 163 - if (cp->capability >= 0 && !capable(cp->capability)) { 164 - err = -EPERM; 165 - goto errout; 166 - } 167 - 168 163 sock->ops = cp->ops; 169 164 170 165 sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot);
-1
net/can/bcm.c
··· 1576 1576 static struct can_proto bcm_can_proto __read_mostly = { 1577 1577 .type = SOCK_DGRAM, 1578 1578 .protocol = CAN_BCM, 1579 - .capability = -1, 1580 1579 .ops = &bcm_ops, 1581 1580 .prot = &bcm_proto, 1582 1581 };
-1
net/can/raw.c
··· 742 742 static struct can_proto raw_can_proto __read_mostly = { 743 743 .type = SOCK_RAW, 744 744 .protocol = CAN_RAW, 745 - .capability = -1, 746 745 .ops = &raw_ops, 747 746 .prot = &raw_proto, 748 747 };
-1
net/dccp/ipv4.c
··· 991 991 .protocol = IPPROTO_DCCP, 992 992 .prot = &dccp_v4_prot, 993 993 .ops = &inet_dccp_ops, 994 - .capability = -1, 995 994 .no_check = 0, 996 995 .flags = INET_PROTOSW_ICSK, 997 996 };
-1
net/dccp/ipv6.c
··· 1185 1185 .protocol = IPPROTO_DCCP, 1186 1186 .prot = &dccp_v6_prot, 1187 1187 .ops = &inet6_dccp_ops, 1188 - .capability = -1, 1189 1188 .flags = INET_PROTOSW_ICSK, 1190 1189 }; 1191 1190
+1 -4
net/ipv4/af_inet.c
··· 325 325 } 326 326 327 327 err = -EPERM; 328 - if (answer->capability > 0 && !capable(answer->capability)) 328 + if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) 329 329 goto out_rcu_unlock; 330 330 331 331 err = -EAFNOSUPPORT; ··· 947 947 .protocol = IPPROTO_TCP, 948 948 .prot = &tcp_prot, 949 949 .ops = &inet_stream_ops, 950 - .capability = -1, 951 950 .no_check = 0, 952 951 .flags = INET_PROTOSW_PERMANENT | 953 952 INET_PROTOSW_ICSK, ··· 957 958 .protocol = IPPROTO_UDP, 958 959 .prot = &udp_prot, 959 960 .ops = &inet_dgram_ops, 960 - .capability = -1, 961 961 .no_check = UDP_CSUM_DEFAULT, 962 962 .flags = INET_PROTOSW_PERMANENT, 963 963 }, ··· 967 969 .protocol = IPPROTO_IP, /* wild card */ 968 970 .prot = &raw_prot, 969 971 .ops = &inet_sockraw_ops, 970 - .capability = CAP_NET_RAW, 971 972 .no_check = UDP_CSUM_DEFAULT, 972 973 .flags = INET_PROTOSW_REUSE, 973 974 }
-1
net/ipv4/udplite.c
··· 64 64 .protocol = IPPROTO_UDPLITE, 65 65 .prot = &udplite_prot, 66 66 .ops = &inet_dgram_ops, 67 - .capability = -1, 68 67 .no_check = 0, /* must checksum (RFC 3828) */ 69 68 .flags = INET_PROTOSW_PERMANENT, 70 69 };
+1 -1
net/ipv6/af_inet6.c
··· 158 158 } 159 159 160 160 err = -EPERM; 161 - if (answer->capability > 0 && !capable(answer->capability)) 161 + if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) 162 162 goto out_rcu_unlock; 163 163 164 164 sock->ops = answer->ops;
-1
net/ipv6/raw.c
··· 1336 1336 .protocol = IPPROTO_IP, /* wild card */ 1337 1337 .prot = &rawv6_prot, 1338 1338 .ops = &inet6_sockraw_ops, 1339 - .capability = CAP_NET_RAW, 1340 1339 .no_check = UDP_CSUM_DEFAULT, 1341 1340 .flags = INET_PROTOSW_REUSE, 1342 1341 };
-1
net/ipv6/tcp_ipv6.c
··· 2112 2112 .protocol = IPPROTO_TCP, 2113 2113 .prot = &tcpv6_prot, 2114 2114 .ops = &inet6_stream_ops, 2115 - .capability = -1, 2116 2115 .no_check = 0, 2117 2116 .flags = INET_PROTOSW_PERMANENT | 2118 2117 INET_PROTOSW_ICSK,
-1
net/ipv6/udp.c
··· 1286 1286 .protocol = IPPROTO_UDP, 1287 1287 .prot = &udpv6_prot, 1288 1288 .ops = &inet6_dgram_ops, 1289 - .capability =-1, 1290 1289 .no_check = UDP_CSUM_DEFAULT, 1291 1290 .flags = INET_PROTOSW_PERMANENT, 1292 1291 };
-1
net/ipv6/udplite.c
··· 62 62 .protocol = IPPROTO_UDPLITE, 63 63 .prot = &udplitev6_prot, 64 64 .ops = &inet6_dgram_ops, 65 - .capability = -1, 66 65 .no_check = 0, 67 66 .flags = INET_PROTOSW_PERMANENT, 68 67 };
-2
net/sctp/ipv6.c
··· 930 930 .protocol = IPPROTO_SCTP, 931 931 .prot = &sctpv6_prot, 932 932 .ops = &inet6_seqpacket_ops, 933 - .capability = -1, 934 933 .no_check = 0, 935 934 .flags = SCTP_PROTOSW_FLAG 936 935 }; ··· 938 939 .protocol = IPPROTO_SCTP, 939 940 .prot = &sctpv6_prot, 940 941 .ops = &inet6_seqpacket_ops, 941 - .capability = -1, 942 942 .no_check = 0, 943 943 .flags = SCTP_PROTOSW_FLAG, 944 944 };
-2
net/sctp/protocol.c
··· 909 909 .protocol = IPPROTO_SCTP, 910 910 .prot = &sctp_prot, 911 911 .ops = &inet_seqpacket_ops, 912 - .capability = -1, 913 912 .no_check = 0, 914 913 .flags = SCTP_PROTOSW_FLAG 915 914 }; ··· 917 918 .protocol = IPPROTO_SCTP, 918 919 .prot = &sctp_prot, 919 920 .ops = &inet_seqpacket_ops, 920 - .capability = -1, 921 921 .no_check = 0, 922 922 .flags = SCTP_PROTOSW_FLAG 923 923 };