Commit 76d7728d authored by Rohit Maheshwari's avatar Rohit Maheshwari Committed by David S. Miller

crypto/chcr: IPV6 code needs to be in CONFIG_IPV6

Error messages seen while building kernel with CONFIG_IPV6
disabled.
Signed-off-by: default avatarRohit Maheshwari <rohitm@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a3ac249a
...@@ -221,6 +221,7 @@ static int chcr_ktls_act_open_req(struct sock *sk, ...@@ -221,6 +221,7 @@ static int chcr_ktls_act_open_req(struct sock *sk,
return cxgb4_l2t_send(tx_info->netdev, skb, tx_info->l2te); return cxgb4_l2t_send(tx_info->netdev, skb, tx_info->l2te);
} }
#if IS_ENABLED(CONFIG_IPV6)
/* /*
* chcr_ktls_act_open_req6: creates TCB entry for ipv6 connection. * chcr_ktls_act_open_req6: creates TCB entry for ipv6 connection.
* @sk - tcp socket. * @sk - tcp socket.
...@@ -270,6 +271,7 @@ static int chcr_ktls_act_open_req6(struct sock *sk, ...@@ -270,6 +271,7 @@ static int chcr_ktls_act_open_req6(struct sock *sk,
return cxgb4_l2t_send(tx_info->netdev, skb, tx_info->l2te); return cxgb4_l2t_send(tx_info->netdev, skb, tx_info->l2te);
} }
#endif /* #if IS_ENABLED(CONFIG_IPV6) */
/* /*
* chcr_setup_connection: create a TCB entry so that TP will form tcp packets. * chcr_setup_connection: create a TCB entry so that TP will form tcp packets.
...@@ -290,21 +292,27 @@ static int chcr_setup_connection(struct sock *sk, ...@@ -290,21 +292,27 @@ static int chcr_setup_connection(struct sock *sk,
tx_info->atid = atid; tx_info->atid = atid;
tx_info->ip_family = sk->sk_family; tx_info->ip_family = sk->sk_family;
if (sk->sk_family == AF_INET || if (sk->sk_family == AF_INET) {
(sk->sk_family == AF_INET6 && !sk->sk_ipv6only && tx_info->ip_family = AF_INET;
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)) { ret = chcr_ktls_act_open_req(sk, tx_info, atid);
#if IS_ENABLED(CONFIG_IPV6)
} else {
if (!sk->sk_ipv6only &&
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED) {
tx_info->ip_family = AF_INET; tx_info->ip_family = AF_INET;
ret = chcr_ktls_act_open_req(sk, tx_info, atid); ret = chcr_ktls_act_open_req(sk, tx_info, atid);
} else { } else {
tx_info->ip_family = AF_INET6; tx_info->ip_family = AF_INET6;
ret = ret = cxgb4_clip_get(tx_info->netdev,
cxgb4_clip_get(tx_info->netdev, (const u32 *)
(const u32 *)&sk->sk_v6_rcv_saddr.in6_u.u6_addr8, &sk->sk_v6_rcv_saddr.s6_addr,
1); 1);
if (ret) if (ret)
goto out; goto out;
ret = chcr_ktls_act_open_req6(sk, tx_info, atid); ret = chcr_ktls_act_open_req6(sk, tx_info, atid);
} }
#endif
}
/* if return type is NET_XMIT_CN, msg will be sent but delayed, mark ret /* if return type is NET_XMIT_CN, msg will be sent but delayed, mark ret
* success, if any other return type clear atid and return that failure. * success, if any other return type clear atid and return that failure.
...@@ -394,11 +402,13 @@ void chcr_ktls_dev_del(struct net_device *netdev, ...@@ -394,11 +402,13 @@ void chcr_ktls_dev_del(struct net_device *netdev,
if (tx_info->l2te) if (tx_info->l2te)
cxgb4_l2t_release(tx_info->l2te); cxgb4_l2t_release(tx_info->l2te);
#if IS_ENABLED(CONFIG_IPV6)
/* clear clip entry */ /* clear clip entry */
if (tx_info->ip_family == AF_INET6) if (tx_info->ip_family == AF_INET6)
cxgb4_clip_release(netdev, cxgb4_clip_release(netdev,
(const u32 *)&sk->sk_v6_daddr.in6_u.u6_addr8, (const u32 *)&sk->sk_v6_daddr.in6_u.u6_addr8,
1); 1);
#endif
/* clear tid */ /* clear tid */
if (tx_info->tid != -1) { if (tx_info->tid != -1) {
...@@ -491,12 +501,16 @@ int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk, ...@@ -491,12 +501,16 @@ int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk,
goto out2; goto out2;
/* get peer ip */ /* get peer ip */
if (sk->sk_family == AF_INET || if (sk->sk_family == AF_INET) {
(sk->sk_family == AF_INET6 && !sk->sk_ipv6only &&
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)) {
memcpy(daaddr, &sk->sk_daddr, 4); memcpy(daaddr, &sk->sk_daddr, 4);
#if IS_ENABLED(CONFIG_IPV6)
} else { } else {
if (!sk->sk_ipv6only &&
ipv6_addr_type(&sk->sk_v6_daddr) == IPV6_ADDR_MAPPED)
memcpy(daaddr, &sk->sk_daddr, 4);
else
memcpy(daaddr, sk->sk_v6_daddr.in6_u.u6_addr8, 16); memcpy(daaddr, sk->sk_v6_daddr.in6_u.u6_addr8, 16);
#endif
} }
/* get the l2t index */ /* get the l2t index */
...@@ -903,7 +917,9 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb, ...@@ -903,7 +917,9 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb,
struct fw_eth_tx_pkt_wr *wr; struct fw_eth_tx_pkt_wr *wr;
struct cpl_tx_pkt_core *cpl; struct cpl_tx_pkt_core *cpl;
u32 ctrl, iplen, maclen; u32 ctrl, iplen, maclen;
#if IS_ENABLED(CONFIG_IPV6)
struct ipv6hdr *ip6; struct ipv6hdr *ip6;
#endif
unsigned int ndesc; unsigned int ndesc;
struct tcphdr *tcp; struct tcphdr *tcp;
int len16, pktlen; int len16, pktlen;
...@@ -958,9 +974,11 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb, ...@@ -958,9 +974,11 @@ chcr_ktls_write_tcp_options(struct chcr_ktls_info *tx_info, struct sk_buff *skb,
/* we need to correct ip header len */ /* we need to correct ip header len */
ip = (struct iphdr *)(buf + maclen); ip = (struct iphdr *)(buf + maclen);
ip->tot_len = htons(pktlen - maclen); ip->tot_len = htons(pktlen - maclen);
#if IS_ENABLED(CONFIG_IPV6)
} else { } else {
ip6 = (struct ipv6hdr *)(buf + maclen); ip6 = (struct ipv6hdr *)(buf + maclen);
ip6->payload_len = htons(pktlen - maclen - iplen); ip6->payload_len = htons(pktlen - maclen - iplen);
#endif
} }
/* now take care of the tcp header, if fin is not set then clear push /* now take care of the tcp header, if fin is not set then clear push
* bit as well, and if fin is set, it will be sent at the last so we * bit as well, and if fin is set, it will be sent at the last so we
......
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