Commit c008b33f authored by Davide Caratti's avatar Davide Caratti Committed by David S. Miller

net/sched: act_csum: compute crc32c on SCTP packets

modify act_csum to compute crc32c on IPv4/IPv6 packets having SCTP in
their payload, and extend UAPI definitions accordingly.
Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ab9d226e
...@@ -21,7 +21,8 @@ enum { ...@@ -21,7 +21,8 @@ enum {
TCA_CSUM_UPDATE_FLAG_IGMP = 4, TCA_CSUM_UPDATE_FLAG_IGMP = 4,
TCA_CSUM_UPDATE_FLAG_TCP = 8, TCA_CSUM_UPDATE_FLAG_TCP = 8,
TCA_CSUM_UPDATE_FLAG_UDP = 16, TCA_CSUM_UPDATE_FLAG_UDP = 16,
TCA_CSUM_UPDATE_FLAG_UDPLITE = 32 TCA_CSUM_UPDATE_FLAG_UDPLITE = 32,
TCA_CSUM_UPDATE_FLAG_SCTP = 64,
}; };
struct tc_csum { struct tc_csum {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <net/tcp.h> #include <net/tcp.h>
#include <net/udp.h> #include <net/udp.h>
#include <net/ip6_checksum.h> #include <net/ip6_checksum.h>
#include <net/sctp/checksum.h>
#include <net/act_api.h> #include <net/act_api.h>
...@@ -322,6 +323,25 @@ static int tcf_csum_ipv6_udp(struct sk_buff *skb, unsigned int ihl, ...@@ -322,6 +323,25 @@ static int tcf_csum_ipv6_udp(struct sk_buff *skb, unsigned int ihl,
return 1; return 1;
} }
static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl,
unsigned int ipl)
{
struct sctphdr *sctph;
if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_SCTP)
return 1;
sctph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*sctph));
if (!sctph)
return 0;
sctph->checksum = sctp_compute_cksum(skb,
skb_network_offset(skb) + ihl);
skb->ip_summed = CHECKSUM_NONE;
return 1;
}
static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags)
{ {
const struct iphdr *iph; const struct iphdr *iph;
...@@ -365,6 +385,11 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) ...@@ -365,6 +385,11 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags)
ntohs(iph->tot_len), 1)) ntohs(iph->tot_len), 1))
goto fail; goto fail;
break; break;
case IPPROTO_SCTP:
if ((update_flags & TCA_CSUM_UPDATE_FLAG_SCTP) &&
!tcf_csum_sctp(skb, iph->ihl * 4, ntohs(iph->tot_len)))
goto fail;
break;
} }
if (update_flags & TCA_CSUM_UPDATE_FLAG_IPV4HDR) { if (update_flags & TCA_CSUM_UPDATE_FLAG_IPV4HDR) {
...@@ -481,6 +506,11 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags) ...@@ -481,6 +506,11 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags)
pl + sizeof(*ip6h), 1)) pl + sizeof(*ip6h), 1))
goto fail; goto fail;
goto done; goto done;
case IPPROTO_SCTP:
if ((update_flags & TCA_CSUM_UPDATE_FLAG_SCTP) &&
!tcf_csum_sctp(skb, hl, pl + sizeof(*ip6h)))
goto fail;
goto done;
default: default:
goto ignore_skb; goto ignore_skb;
} }
......
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