Skip to content

Commit 76d7728

Browse files
rmchelsiodavem330
authored andcommitted
crypto/chcr: IPV6 code needs to be in CONFIG_IPV6
Error messages seen while building kernel with CONFIG_IPV6 disabled. Signed-off-by: Rohit Maheshwari <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3ac249 commit 76d7728

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

drivers/crypto/chelsio/chcr_ktls.c

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static int chcr_ktls_act_open_req(struct sock *sk,
221221
return cxgb4_l2t_send(tx_info->netdev, skb, tx_info->l2te);
222222
}
223223

224+
#if IS_ENABLED(CONFIG_IPV6)
224225
/*
225226
* chcr_ktls_act_open_req6: creates TCB entry for ipv6 connection.
226227
* @sk - tcp socket.
@@ -270,6 +271,7 @@ static int chcr_ktls_act_open_req6(struct sock *sk,
270271

271272
return cxgb4_l2t_send(tx_info->netdev, skb, tx_info->l2te);
272273
}
274+
#endif /* #if IS_ENABLED(CONFIG_IPV6) */
273275

274276
/*
275277
* chcr_setup_connection: create a TCB entry so that TP will form tcp packets.
@@ -290,20 +292,26 @@ static int chcr_setup_connection(struct sock *sk,
290292
tx_info->atid = atid;
291293
tx_info->ip_family = sk->sk_family;
292294

293-
if (sk->sk_family == AF_INET ||
294-
(sk->sk_family == AF_INET6 && !sk->sk_ipv6only &&
295-
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)) {
295+
if (sk->sk_family == AF_INET) {
296296
tx_info->ip_family = AF_INET;
297297
ret = chcr_ktls_act_open_req(sk, tx_info, atid);
298+
#if IS_ENABLED(CONFIG_IPV6)
298299
} else {
299-
tx_info->ip_family = AF_INET6;
300-
ret =
301-
cxgb4_clip_get(tx_info->netdev,
302-
(const u32 *)&sk->sk_v6_rcv_saddr.in6_u.u6_addr8,
303-
1);
304-
if (ret)
305-
goto out;
306-
ret = chcr_ktls_act_open_req6(sk, tx_info, atid);
300+
if (!sk->sk_ipv6only &&
301+
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED) {
302+
tx_info->ip_family = AF_INET;
303+
ret = chcr_ktls_act_open_req(sk, tx_info, atid);
304+
} else {
305+
tx_info->ip_family = AF_INET6;
306+
ret = cxgb4_clip_get(tx_info->netdev,
307+
(const u32 *)
308+
&sk->sk_v6_rcv_saddr.s6_addr,
309+
1);
310+
if (ret)
311+
goto out;
312+
ret = chcr_ktls_act_open_req6(sk, tx_info, atid);
313+
}
314+
#endif
307315
}
308316

309317
/* if return type is NET_XMIT_CN, msg will be sent but delayed, mark ret
@@ -394,11 +402,13 @@ void chcr_ktls_dev_del(struct net_device *netdev,
394402
if (tx_info->l2te)
395403
cxgb4_l2t_release(tx_info->l2te);
396404

405+
#if IS_ENABLED(CONFIG_IPV6)
397406
/* clear clip entry */
398407
if (tx_info->ip_family == AF_INET6)
399408
cxgb4_clip_release(netdev,
400409
(const u32 *)&sk->sk_v6_daddr.in6_u.u6_addr8,
401410
1);
411+
#endif
402412

403413
/* clear tid */
404414
if (tx_info->tid != -1) {
@@ -491,12 +501,16 @@ int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk,
491501
goto out2;
492502

493503
/* get peer ip */
494-
if (sk->sk_family == AF_INET ||
495-
(sk->sk_family == AF_INET6 && !sk->sk_ipv6only &&
496-
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)) {
504+
if (sk->sk_family == AF_INET) {
497505
memcpy(daaddr, &sk->sk_daddr, 4);
506+
#if IS_ENABLED(CONFIG_IPV6)
498507
} else {
499-
memcpy(daaddr, sk->sk_v6_daddr.in6_u.u6_addr8, 16);
508+
if (!sk->sk_ipv6only &&
509+
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)
510+
memcpy(daaddr, &sk->sk_daddr, 4);
511+
else
512+
memcpy(daaddr, sk->sk_v6_daddr.in6_u.u6_addr8, 16);
513+
#endif
500514
}
501515

502516
/* get the l2t index */
@@ -903,7 +917,9 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb,
903917
struct fw_eth_tx_pkt_wr *wr;
904918
struct cpl_tx_pkt_core *cpl;
905919
u32 ctrl, iplen, maclen;
920+
#if IS_ENABLED(CONFIG_IPV6)
906921
struct ipv6hdr *ip6;
922+
#endif
907923
unsigned int ndesc;
908924
struct tcphdr *tcp;
909925
int len16, pktlen;
@@ -958,9 +974,11 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb,
958974
/* we need to correct ip header len */
959975
ip = (struct iphdr *)(buf + maclen);
960976
ip->tot_len = htons(pktlen - maclen);
977+
#if IS_ENABLED(CONFIG_IPV6)
961978
} else {
962979
ip6 = (struct ipv6hdr *)(buf + maclen);
963980
ip6->payload_len = htons(pktlen - maclen - iplen);
981+
#endif
964982
}
965983
/* now take care of the tcp header, if fin is not set then clear push
966984
* bit as well, and if fin is set, it will be sent at the last so we

0 commit comments

Comments
 (0)