[RFCv2 net-next 060/167] net: sctp: use netdev feature helpers
From: Jian Shen <shenjian15@huawei.com>
Date: 2021-09-29 16:03:36
Subsystem:
networking [general], sctp protocol, the rest · Maintainers:
"David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marcelo Ricardo Leitner, Xin Long, Linus Torvalds
Use netdev_feature_xxx helpers to replace the logical operation for netdev features. Signed-off-by: Jian Shen <shenjian15@huawei.com> --- net/sctp/offload.c | 12 +++++++++--- net/sctp/output.c | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/net/sctp/offload.c b/net/sctp/offload.c
index eb874e3c399a..c49464811614 100644
--- a/net/sctp/offload.c
+++ b/net/sctp/offload.c@@ -39,6 +39,7 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, netdev_features_t features) { struct sk_buff *segs = ERR_PTR(-EINVAL); + netdev_features_t tmp; struct sctphdr *sh; if (!skb_is_gso_sctp(skb))
@@ -50,7 +51,9 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, __skb_pull(skb, sizeof(*sh)); - if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { + netdev_feature_copy(&tmp, features); + netdev_feature_set_bit(NETIF_F_GSO_ROBUST_BIT, &tmp); + if (skb_gso_ok(skb, tmp)) { /* Packet is from an untrusted source, reset gso_segs. */ struct skb_shared_info *pinfo = skb_shinfo(skb); struct sk_buff *frag_iter;
@@ -68,12 +71,15 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, goto out; } - segs = skb_segment(skb, (features | NETIF_F_HW_CSUM) & ~NETIF_F_SG); + netdev_feature_copy(&tmp, features); + netdev_feature_set_bit(NETIF_F_HW_CSUM_BIT, &tmp); + netdev_feature_clear_bit(NETIF_F_SG_BIT, &tmp); + segs = skb_segment(skb, tmp); if (IS_ERR(segs)) goto out; /* All that is left is update SCTP CRC if necessary */ - if (!(features & NETIF_F_SCTP_CRC)) { + if (!netdev_feature_test_bit(NETIF_F_SCTP_CRC_BIT, features)) { for (skb = segs; skb; skb = skb->next) { if (skb->ip_summed == CHECKSUM_PARTIAL) { sh = sctp_hdr(skb);
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 4dfb5ea82b05..bbaadde69358 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c@@ -543,7 +543,7 @@ static int sctp_packet_pack(struct sctp_packet *packet, if (sctp_checksum_disable) return 1; - if (!(tp->dst->dev->features & NETIF_F_SCTP_CRC) || + if (!netdev_feature_test_bit(NETIF_F_SCTP_CRC_BIT, tp->dst->dev->features) || dst_xfrm(tp->dst) || packet->ipfragok || tp->encap_port) { struct sctphdr *sh = (struct sctphdr *)skb_transport_header(head);
--
2.33.0