mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 22:51:35 +00:00
crypto/chtls:Fix compile error when CONFIG_IPV6 is disabled
Fix compile errors,warnings when CONFIG_IPV6 is disabled and
inconsistent indenting.
v1->v2:
- Corrected errors/warnings reported when used newer gcc version,
unused array.
Fixes: 6abde0b241
("crypto/chtls: IPv6 support for inline TLS")
Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6761893eea
commit
a624a86510
@ -389,10 +389,6 @@ static inline void copy_hash_init_values(char *key, int digestsize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u8 sgl_lengths[20] = {
|
|
||||||
0, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Number of len fields(8) * size of one addr field */
|
/* Number of len fields(8) * size of one addr field */
|
||||||
#define PHYSDSGL_MAX_LEN_SIZE 16
|
#define PHYSDSGL_MAX_LEN_SIZE 16
|
||||||
|
|
||||||
|
@ -93,8 +93,10 @@ static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
|
|||||||
struct sock *sk)
|
struct sock *sk)
|
||||||
{
|
{
|
||||||
struct net_device *ndev = cdev->ports[0];
|
struct net_device *ndev = cdev->ports[0];
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
struct net_device *temp;
|
struct net_device *temp;
|
||||||
int addr_type;
|
int addr_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (sk->sk_family) {
|
switch (sk->sk_family) {
|
||||||
case PF_INET:
|
case PF_INET:
|
||||||
@ -102,19 +104,21 @@ static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
|
|||||||
return ndev;
|
return ndev;
|
||||||
ndev = ip_dev_find(&init_net, inet_sk(sk)->inet_rcv_saddr);
|
ndev = ip_dev_find(&init_net, inet_sk(sk)->inet_rcv_saddr);
|
||||||
break;
|
break;
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
case PF_INET6:
|
case PF_INET6:
|
||||||
addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
|
addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
|
||||||
if (likely(addr_type == IPV6_ADDR_ANY))
|
if (likely(addr_type == IPV6_ADDR_ANY))
|
||||||
return ndev;
|
return ndev;
|
||||||
|
|
||||||
for_each_netdev_rcu(&init_net, temp) {
|
for_each_netdev_rcu(&init_net, temp) {
|
||||||
if (ipv6_chk_addr(&init_net, (struct in6_addr *)
|
if (ipv6_chk_addr(&init_net, (struct in6_addr *)
|
||||||
&sk->sk_v6_rcv_saddr, temp, 1)) {
|
&sk->sk_v6_rcv_saddr, temp, 1)) {
|
||||||
ndev = temp;
|
ndev = temp;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -476,8 +480,10 @@ void chtls_destroy_sock(struct sock *sk)
|
|||||||
csk->cdev = NULL;
|
csk->cdev = NULL;
|
||||||
if (sk->sk_family == AF_INET)
|
if (sk->sk_family == AF_INET)
|
||||||
sk->sk_prot = &tcp_prot;
|
sk->sk_prot = &tcp_prot;
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
else
|
else
|
||||||
sk->sk_prot = &tcpv6_prot;
|
sk->sk_prot = &tcpv6_prot;
|
||||||
|
#endif
|
||||||
sk->sk_prot->destroy(sk);
|
sk->sk_prot->destroy(sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,14 +635,15 @@ static void chtls_reset_synq(struct listen_ctx *listen_ctx)
|
|||||||
int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
|
int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
|
||||||
{
|
{
|
||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
|
bool clip_valid = false;
|
||||||
|
#endif
|
||||||
struct listen_ctx *ctx;
|
struct listen_ctx *ctx;
|
||||||
struct adapter *adap;
|
struct adapter *adap;
|
||||||
struct port_info *pi;
|
struct port_info *pi;
|
||||||
bool clip_valid;
|
int ret = 0;
|
||||||
int stid;
|
int stid;
|
||||||
int ret;
|
|
||||||
|
|
||||||
clip_valid = false;
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
ndev = chtls_find_netdev(cdev, sk);
|
ndev = chtls_find_netdev(cdev, sk);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
@ -674,6 +681,7 @@ int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
|
|||||||
inet_sk(sk)->inet_rcv_saddr,
|
inet_sk(sk)->inet_rcv_saddr,
|
||||||
inet_sk(sk)->inet_sport, 0,
|
inet_sk(sk)->inet_sport, 0,
|
||||||
cdev->lldi->rxq_ids[0]);
|
cdev->lldi->rxq_ids[0]);
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
} else {
|
} else {
|
||||||
int addr_type;
|
int addr_type;
|
||||||
|
|
||||||
@ -689,6 +697,7 @@ int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
|
|||||||
&sk->sk_v6_rcv_saddr,
|
&sk->sk_v6_rcv_saddr,
|
||||||
inet_sk(sk)->inet_sport,
|
inet_sk(sk)->inet_sport,
|
||||||
cdev->lldi->rxq_ids[0]);
|
cdev->lldi->rxq_ids[0]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
ret = net_xmit_errno(ret);
|
ret = net_xmit_errno(ret);
|
||||||
@ -696,8 +705,10 @@ int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
|
|||||||
goto del_hash;
|
goto del_hash;
|
||||||
return 0;
|
return 0;
|
||||||
del_hash:
|
del_hash:
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
if (clip_valid)
|
if (clip_valid)
|
||||||
cxgb4_clip_release(ndev, (const u32 *)&sk->sk_v6_rcv_saddr, 1);
|
cxgb4_clip_release(ndev, (const u32 *)&sk->sk_v6_rcv_saddr, 1);
|
||||||
|
#endif
|
||||||
listen_hash_del(cdev, sk);
|
listen_hash_del(cdev, sk);
|
||||||
free_stid:
|
free_stid:
|
||||||
cxgb4_free_stid(cdev->tids, stid, sk->sk_family);
|
cxgb4_free_stid(cdev->tids, stid, sk->sk_family);
|
||||||
@ -711,8 +722,6 @@ free_ctx:
|
|||||||
void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
|
void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
|
||||||
{
|
{
|
||||||
struct listen_ctx *listen_ctx;
|
struct listen_ctx *listen_ctx;
|
||||||
struct chtls_sock *csk;
|
|
||||||
int addr_type = 0;
|
|
||||||
int stid;
|
int stid;
|
||||||
|
|
||||||
stid = listen_hash_del(cdev, sk);
|
stid = listen_hash_del(cdev, sk);
|
||||||
@ -725,7 +734,11 @@ void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
|
|||||||
cxgb4_remove_server(cdev->lldi->ports[0], stid,
|
cxgb4_remove_server(cdev->lldi->ports[0], stid,
|
||||||
cdev->lldi->rxq_ids[0], sk->sk_family == PF_INET6);
|
cdev->lldi->rxq_ids[0], sk->sk_family == PF_INET6);
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
if (sk->sk_family == PF_INET6) {
|
if (sk->sk_family == PF_INET6) {
|
||||||
|
struct chtls_sock *csk;
|
||||||
|
int addr_type = 0;
|
||||||
|
|
||||||
csk = rcu_dereference_sk_user_data(sk);
|
csk = rcu_dereference_sk_user_data(sk);
|
||||||
addr_type = ipv6_addr_type((const struct in6_addr *)
|
addr_type = ipv6_addr_type((const struct in6_addr *)
|
||||||
&sk->sk_v6_rcv_saddr);
|
&sk->sk_v6_rcv_saddr);
|
||||||
@ -733,6 +746,7 @@ void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
|
|||||||
cxgb4_clip_release(csk->egress_dev, (const u32 *)
|
cxgb4_clip_release(csk->egress_dev, (const u32 *)
|
||||||
&sk->sk_v6_rcv_saddr, 1);
|
&sk->sk_v6_rcv_saddr, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
chtls_disconnect_acceptq(sk);
|
chtls_disconnect_acceptq(sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,9 +955,11 @@ static unsigned int chtls_select_mss(const struct chtls_sock *csk,
|
|||||||
tp = tcp_sk(sk);
|
tp = tcp_sk(sk);
|
||||||
tcpoptsz = 0;
|
tcpoptsz = 0;
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
if (sk->sk_family == AF_INET6)
|
if (sk->sk_family == AF_INET6)
|
||||||
iphdrsz = sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
|
iphdrsz = sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
iphdrsz = sizeof(struct iphdr) + sizeof(struct tcphdr);
|
iphdrsz = sizeof(struct iphdr) + sizeof(struct tcphdr);
|
||||||
if (req->tcpopt.tstamp)
|
if (req->tcpopt.tstamp)
|
||||||
tcpoptsz += round_up(TCPOLEN_TIMESTAMP, 4);
|
tcpoptsz += round_up(TCPOLEN_TIMESTAMP, 4);
|
||||||
@ -1091,13 +1107,13 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
|
|||||||
const struct cpl_pass_accept_req *req,
|
const struct cpl_pass_accept_req *req,
|
||||||
struct chtls_dev *cdev)
|
struct chtls_dev *cdev)
|
||||||
{
|
{
|
||||||
|
struct neighbour *n = NULL;
|
||||||
struct inet_sock *newinet;
|
struct inet_sock *newinet;
|
||||||
const struct iphdr *iph;
|
const struct iphdr *iph;
|
||||||
struct tls_context *ctx;
|
struct tls_context *ctx;
|
||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
struct chtls_sock *csk;
|
struct chtls_sock *csk;
|
||||||
struct dst_entry *dst;
|
struct dst_entry *dst;
|
||||||
struct neighbour *n;
|
|
||||||
struct tcp_sock *tp;
|
struct tcp_sock *tp;
|
||||||
struct sock *newsk;
|
struct sock *newsk;
|
||||||
u16 port_id;
|
u16 port_id;
|
||||||
@ -1115,6 +1131,7 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
|
|||||||
goto free_sk;
|
goto free_sk;
|
||||||
|
|
||||||
n = dst_neigh_lookup(dst, &iph->saddr);
|
n = dst_neigh_lookup(dst, &iph->saddr);
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
} else {
|
} else {
|
||||||
const struct ipv6hdr *ip6h;
|
const struct ipv6hdr *ip6h;
|
||||||
struct flowi6 fl6;
|
struct flowi6 fl6;
|
||||||
@ -1131,6 +1148,7 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
|
|||||||
if (IS_ERR(dst))
|
if (IS_ERR(dst))
|
||||||
goto free_sk;
|
goto free_sk;
|
||||||
n = dst_neigh_lookup(dst, &ip6h->saddr);
|
n = dst_neigh_lookup(dst, &ip6h->saddr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!n)
|
if (!n)
|
||||||
goto free_sk;
|
goto free_sk;
|
||||||
@ -1158,6 +1176,7 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
|
|||||||
newinet->inet_daddr = iph->saddr;
|
newinet->inet_daddr = iph->saddr;
|
||||||
newinet->inet_rcv_saddr = iph->daddr;
|
newinet->inet_rcv_saddr = iph->daddr;
|
||||||
newinet->inet_saddr = iph->daddr;
|
newinet->inet_saddr = iph->daddr;
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
} else {
|
} else {
|
||||||
struct tcp6_sock *newtcp6sk = (struct tcp6_sock *)newsk;
|
struct tcp6_sock *newtcp6sk = (struct tcp6_sock *)newsk;
|
||||||
struct inet_request_sock *treq = inet_rsk(oreq);
|
struct inet_request_sock *treq = inet_rsk(oreq);
|
||||||
@ -1175,6 +1194,7 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
|
|||||||
newinet->inet_opt = NULL;
|
newinet->inet_opt = NULL;
|
||||||
newinet->inet_daddr = LOOPBACK4_IPV6;
|
newinet->inet_daddr = LOOPBACK4_IPV6;
|
||||||
newinet->inet_saddr = LOOPBACK4_IPV6;
|
newinet->inet_saddr = LOOPBACK4_IPV6;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
oreq->ts_recent = PASS_OPEN_TID_G(ntohl(req->tos_stid));
|
oreq->ts_recent = PASS_OPEN_TID_G(ntohl(req->tos_stid));
|
||||||
@ -1337,10 +1357,12 @@ static void chtls_pass_accept_request(struct sock *sk,
|
|||||||
if (iph->version == 0x4) {
|
if (iph->version == 0x4) {
|
||||||
chtls_set_req_addr(oreq, iph->daddr, iph->saddr);
|
chtls_set_req_addr(oreq, iph->daddr, iph->saddr);
|
||||||
ip_dsfield = ipv4_get_dsfield(iph);
|
ip_dsfield = ipv4_get_dsfield(iph);
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
} else {
|
} else {
|
||||||
inet_rsk(oreq)->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
|
inet_rsk(oreq)->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
|
||||||
inet_rsk(oreq)->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
|
inet_rsk(oreq)->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
|
||||||
ip_dsfield = ipv6_get_dsfield(ipv6_hdr(skb));
|
ip_dsfield = ipv6_get_dsfield(ipv6_hdr(skb));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (req->tcpopt.wsf <= 14 &&
|
if (req->tcpopt.wsf <= 14 &&
|
||||||
sock_net(sk)->ipv4.sysctl_tcp_window_scaling) {
|
sock_net(sk)->ipv4.sysctl_tcp_window_scaling) {
|
||||||
|
@ -608,9 +608,11 @@ static void __init chtls_init_ulp_ops(void)
|
|||||||
chtls_cpl_prot.recvmsg = chtls_recvmsg;
|
chtls_cpl_prot.recvmsg = chtls_recvmsg;
|
||||||
chtls_cpl_prot.setsockopt = chtls_setsockopt;
|
chtls_cpl_prot.setsockopt = chtls_setsockopt;
|
||||||
chtls_cpl_prot.getsockopt = chtls_getsockopt;
|
chtls_cpl_prot.getsockopt = chtls_getsockopt;
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
chtls_cpl_protv6 = chtls_cpl_prot;
|
chtls_cpl_protv6 = chtls_cpl_prot;
|
||||||
chtls_init_rsk_ops(&chtls_cpl_protv6, &chtls_rsk_opsv6,
|
chtls_init_rsk_ops(&chtls_cpl_protv6, &chtls_rsk_opsv6,
|
||||||
&tcpv6_prot, PF_INET6);
|
&tcpv6_prot, PF_INET6);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init chtls_register(void)
|
static int __init chtls_register(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user