Commit 13f18aa0 authored by Eric Paris's avatar Eric Paris Committed by David S. Miller

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: default avatarEric Paris <eparis@redhat.com>
Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 89794a6f
...@@ -32,14 +32,12 @@ ...@@ -32,14 +32,12 @@
* struct can_proto - CAN protocol structure * struct can_proto - CAN protocol structure
* @type: type argument in socket() syscall, e.g. SOCK_DGRAM. * @type: type argument in socket() syscall, e.g. SOCK_DGRAM.
* @protocol: protocol number in socket() syscall. * @protocol: protocol number in socket() syscall.
* @capability: capability needed to open the socket, or -1 for no restriction.
* @ops: pointer to struct proto_ops for sock->ops. * @ops: pointer to struct proto_ops for sock->ops.
* @prot: pointer to struct proto structure. * @prot: pointer to struct proto structure.
*/ */
struct can_proto { struct can_proto {
int type; int type;
int protocol; int protocol;
int capability;
struct proto_ops *ops; struct proto_ops *ops;
struct proto *prot; struct proto *prot;
}; };
......
...@@ -82,10 +82,6 @@ struct inet_protosw { ...@@ -82,10 +82,6 @@ struct inet_protosw {
struct proto *prot; struct proto *prot;
const struct proto_ops *ops; const struct proto_ops *ops;
int capability; /* Which (if any) capability do
* we need to use this socket
* interface?
*/
char no_check; /* checksum on rcv/xmit/none? */ char no_check; /* checksum on rcv/xmit/none? */
unsigned char flags; /* See INET_PROTOSW_* below. */ unsigned char flags; /* See INET_PROTOSW_* below. */
}; };
......
...@@ -160,11 +160,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol) ...@@ -160,11 +160,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
goto errout; goto errout;
} }
if (cp->capability >= 0 && !capable(cp->capability)) {
err = -EPERM;
goto errout;
}
sock->ops = cp->ops; sock->ops = cp->ops;
sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot); sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot);
......
...@@ -1576,7 +1576,6 @@ static struct proto bcm_proto __read_mostly = { ...@@ -1576,7 +1576,6 @@ static struct proto bcm_proto __read_mostly = {
static struct can_proto bcm_can_proto __read_mostly = { static struct can_proto bcm_can_proto __read_mostly = {
.type = SOCK_DGRAM, .type = SOCK_DGRAM,
.protocol = CAN_BCM, .protocol = CAN_BCM,
.capability = -1,
.ops = &bcm_ops, .ops = &bcm_ops,
.prot = &bcm_proto, .prot = &bcm_proto,
}; };
......
...@@ -742,7 +742,6 @@ static struct proto raw_proto __read_mostly = { ...@@ -742,7 +742,6 @@ static struct proto raw_proto __read_mostly = {
static struct can_proto raw_can_proto __read_mostly = { static struct can_proto raw_can_proto __read_mostly = {
.type = SOCK_RAW, .type = SOCK_RAW,
.protocol = CAN_RAW, .protocol = CAN_RAW,
.capability = -1,
.ops = &raw_ops, .ops = &raw_ops,
.prot = &raw_proto, .prot = &raw_proto,
}; };
......
...@@ -991,7 +991,6 @@ static struct inet_protosw dccp_v4_protosw = { ...@@ -991,7 +991,6 @@ static struct inet_protosw dccp_v4_protosw = {
.protocol = IPPROTO_DCCP, .protocol = IPPROTO_DCCP,
.prot = &dccp_v4_prot, .prot = &dccp_v4_prot,
.ops = &inet_dccp_ops, .ops = &inet_dccp_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = INET_PROTOSW_ICSK, .flags = INET_PROTOSW_ICSK,
}; };
......
...@@ -1185,7 +1185,6 @@ static struct inet_protosw dccp_v6_protosw = { ...@@ -1185,7 +1185,6 @@ static struct inet_protosw dccp_v6_protosw = {
.protocol = IPPROTO_DCCP, .protocol = IPPROTO_DCCP,
.prot = &dccp_v6_prot, .prot = &dccp_v6_prot,
.ops = &inet6_dccp_ops, .ops = &inet6_dccp_ops,
.capability = -1,
.flags = INET_PROTOSW_ICSK, .flags = INET_PROTOSW_ICSK,
}; };
......
...@@ -325,7 +325,7 @@ lookup_protocol: ...@@ -325,7 +325,7 @@ lookup_protocol:
} }
err = -EPERM; err = -EPERM;
if (answer->capability > 0 && !capable(answer->capability)) if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW))
goto out_rcu_unlock; goto out_rcu_unlock;
err = -EAFNOSUPPORT; err = -EAFNOSUPPORT;
...@@ -947,7 +947,6 @@ static struct inet_protosw inetsw_array[] = ...@@ -947,7 +947,6 @@ static struct inet_protosw inetsw_array[] =
.protocol = IPPROTO_TCP, .protocol = IPPROTO_TCP,
.prot = &tcp_prot, .prot = &tcp_prot,
.ops = &inet_stream_ops, .ops = &inet_stream_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = INET_PROTOSW_PERMANENT | .flags = INET_PROTOSW_PERMANENT |
INET_PROTOSW_ICSK, INET_PROTOSW_ICSK,
...@@ -958,7 +957,6 @@ static struct inet_protosw inetsw_array[] = ...@@ -958,7 +957,6 @@ static struct inet_protosw inetsw_array[] =
.protocol = IPPROTO_UDP, .protocol = IPPROTO_UDP,
.prot = &udp_prot, .prot = &udp_prot,
.ops = &inet_dgram_ops, .ops = &inet_dgram_ops,
.capability = -1,
.no_check = UDP_CSUM_DEFAULT, .no_check = UDP_CSUM_DEFAULT,
.flags = INET_PROTOSW_PERMANENT, .flags = INET_PROTOSW_PERMANENT,
}, },
...@@ -969,7 +967,6 @@ static struct inet_protosw inetsw_array[] = ...@@ -969,7 +967,6 @@ static struct inet_protosw inetsw_array[] =
.protocol = IPPROTO_IP, /* wild card */ .protocol = IPPROTO_IP, /* wild card */
.prot = &raw_prot, .prot = &raw_prot,
.ops = &inet_sockraw_ops, .ops = &inet_sockraw_ops,
.capability = CAP_NET_RAW,
.no_check = UDP_CSUM_DEFAULT, .no_check = UDP_CSUM_DEFAULT,
.flags = INET_PROTOSW_REUSE, .flags = INET_PROTOSW_REUSE,
} }
......
...@@ -64,7 +64,6 @@ static struct inet_protosw udplite4_protosw = { ...@@ -64,7 +64,6 @@ static struct inet_protosw udplite4_protosw = {
.protocol = IPPROTO_UDPLITE, .protocol = IPPROTO_UDPLITE,
.prot = &udplite_prot, .prot = &udplite_prot,
.ops = &inet_dgram_ops, .ops = &inet_dgram_ops,
.capability = -1,
.no_check = 0, /* must checksum (RFC 3828) */ .no_check = 0, /* must checksum (RFC 3828) */
.flags = INET_PROTOSW_PERMANENT, .flags = INET_PROTOSW_PERMANENT,
}; };
......
...@@ -158,7 +158,7 @@ lookup_protocol: ...@@ -158,7 +158,7 @@ lookup_protocol:
} }
err = -EPERM; err = -EPERM;
if (answer->capability > 0 && !capable(answer->capability)) if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW))
goto out_rcu_unlock; goto out_rcu_unlock;
sock->ops = answer->ops; sock->ops = answer->ops;
......
...@@ -1336,7 +1336,6 @@ static struct inet_protosw rawv6_protosw = { ...@@ -1336,7 +1336,6 @@ static struct inet_protosw rawv6_protosw = {
.protocol = IPPROTO_IP, /* wild card */ .protocol = IPPROTO_IP, /* wild card */
.prot = &rawv6_prot, .prot = &rawv6_prot,
.ops = &inet6_sockraw_ops, .ops = &inet6_sockraw_ops,
.capability = CAP_NET_RAW,
.no_check = UDP_CSUM_DEFAULT, .no_check = UDP_CSUM_DEFAULT,
.flags = INET_PROTOSW_REUSE, .flags = INET_PROTOSW_REUSE,
}; };
......
...@@ -2112,7 +2112,6 @@ static struct inet_protosw tcpv6_protosw = { ...@@ -2112,7 +2112,6 @@ static struct inet_protosw tcpv6_protosw = {
.protocol = IPPROTO_TCP, .protocol = IPPROTO_TCP,
.prot = &tcpv6_prot, .prot = &tcpv6_prot,
.ops = &inet6_stream_ops, .ops = &inet6_stream_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = INET_PROTOSW_PERMANENT | .flags = INET_PROTOSW_PERMANENT |
INET_PROTOSW_ICSK, INET_PROTOSW_ICSK,
......
...@@ -1286,7 +1286,6 @@ static struct inet_protosw udpv6_protosw = { ...@@ -1286,7 +1286,6 @@ static struct inet_protosw udpv6_protosw = {
.protocol = IPPROTO_UDP, .protocol = IPPROTO_UDP,
.prot = &udpv6_prot, .prot = &udpv6_prot,
.ops = &inet6_dgram_ops, .ops = &inet6_dgram_ops,
.capability =-1,
.no_check = UDP_CSUM_DEFAULT, .no_check = UDP_CSUM_DEFAULT,
.flags = INET_PROTOSW_PERMANENT, .flags = INET_PROTOSW_PERMANENT,
}; };
......
...@@ -62,7 +62,6 @@ static struct inet_protosw udplite6_protosw = { ...@@ -62,7 +62,6 @@ static struct inet_protosw udplite6_protosw = {
.protocol = IPPROTO_UDPLITE, .protocol = IPPROTO_UDPLITE,
.prot = &udplitev6_prot, .prot = &udplitev6_prot,
.ops = &inet6_dgram_ops, .ops = &inet6_dgram_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = INET_PROTOSW_PERMANENT, .flags = INET_PROTOSW_PERMANENT,
}; };
......
...@@ -930,7 +930,6 @@ static struct inet_protosw sctpv6_seqpacket_protosw = { ...@@ -930,7 +930,6 @@ static struct inet_protosw sctpv6_seqpacket_protosw = {
.protocol = IPPROTO_SCTP, .protocol = IPPROTO_SCTP,
.prot = &sctpv6_prot, .prot = &sctpv6_prot,
.ops = &inet6_seqpacket_ops, .ops = &inet6_seqpacket_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = SCTP_PROTOSW_FLAG .flags = SCTP_PROTOSW_FLAG
}; };
...@@ -939,7 +938,6 @@ static struct inet_protosw sctpv6_stream_protosw = { ...@@ -939,7 +938,6 @@ static struct inet_protosw sctpv6_stream_protosw = {
.protocol = IPPROTO_SCTP, .protocol = IPPROTO_SCTP,
.prot = &sctpv6_prot, .prot = &sctpv6_prot,
.ops = &inet6_seqpacket_ops, .ops = &inet6_seqpacket_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = SCTP_PROTOSW_FLAG, .flags = SCTP_PROTOSW_FLAG,
}; };
......
...@@ -909,7 +909,6 @@ static struct inet_protosw sctp_seqpacket_protosw = { ...@@ -909,7 +909,6 @@ static struct inet_protosw sctp_seqpacket_protosw = {
.protocol = IPPROTO_SCTP, .protocol = IPPROTO_SCTP,
.prot = &sctp_prot, .prot = &sctp_prot,
.ops = &inet_seqpacket_ops, .ops = &inet_seqpacket_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = SCTP_PROTOSW_FLAG .flags = SCTP_PROTOSW_FLAG
}; };
...@@ -918,7 +917,6 @@ static struct inet_protosw sctp_stream_protosw = { ...@@ -918,7 +917,6 @@ static struct inet_protosw sctp_stream_protosw = {
.protocol = IPPROTO_SCTP, .protocol = IPPROTO_SCTP,
.prot = &sctp_prot, .prot = &sctp_prot,
.ops = &inet_seqpacket_ops, .ops = &inet_seqpacket_ops,
.capability = -1,
.no_check = 0, .no_check = 0,
.flags = SCTP_PROTOSW_FLAG .flags = SCTP_PROTOSW_FLAG
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment