net/sched: act_csum: add support for SCTP checksum
Subsystems (3)
cover net/sched: act_csum: add support for SCTP checksum
This series extends current act_csum functionality to allow computation of SCTP checksums. Patch 1 ensures LIBCRC32C will be selected if NET_ACT_CSUM is selected. Patch 2 extends act_csum to handle IPPROTO_SCTP protocol in IPv4/IPv6 header, and eventually compute the CRC32c value.
Davide Caratti (2):
net/sched: Kconfig: select LIBCRC32C if NET_ACT_CSUM is selected net/sched: act_csum: compute crc32c on SCTP packets
include/uapi/linux/tc_act/tc_csum.h | 3 ++- net/sched/Kconfig | 1 + net/sched/act_csum.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
PATCH 1/2 net/sched: Kconfig: select LIBCRC32C if NET_ACT_CSUM is selected
LIBCRC32C is needed to compute crc32c on SCTP packets.
--- net/sched/Kconfig | 1 + 1 file changed, 1 insertion(+)
net/sched/Kconfig +1 -0
@@ -707,6 +707,7 @@ config NET_ACT_SKBEDIT config NET_ACT_CSUM tristate "Checksum Updating" depends on NET_CLS_ACT && INET + select LIBCRC32C ---help--- Say Y here to update some common checksum after some direct packet alterations.
Signature · 1 line
2.7.4
PATCH 2/2 net/sched: act_csum: compute crc32c on SCTP packets
In reply to Davide Carattimodify act_csum to compute crc32c on IPv4/IPv6 packets having SCTP in their payload, and extend UAPI definitions accordingly.
--- include/uapi/linux/tc_act/tc_csum.h | 3 ++- net/sched/act_csum.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)
include/uapi/linux/tc_act/tc_csum.h +2 -1
@@ -21,7 +21,8 @@ enum {TCA_CSUM_UPDATE_FLAG_IGMP =4 ,TCA_CSUM_UPDATE_FLAG_TCP =8 ,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 {
net/sched/act_csum.c +32 -0
@@ -30,6 +30,7 @@#include <net/tcp.h> #include <net/udp.h> #include <net/ip6_checksum.h> +#include <net/sctp/checksum.h> #include <net/act_api.h>
@@ -322,6 +323,25 @@ static int tcf_csum_ipv6_udp(struct sk_buff *skb, unsigned int ihl,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) {const struct iphdr *iph;
@@ -365,6 +385,12 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) ntohs(iph->tot_len), 1)) goto fail;break ; +case IPPROTO_SCTP : +if (update_flags &TCA_CSUM_UPDATE_FLAG_SCTP ) +if (!tcf_csum_sctp (skb, iph->ihl *4 , +ntohs (iph->tot_len))) + goto fail; +break ; }if (update_flags &TCA_CSUM_UPDATE_FLAG_IPV4HDR ) {
@@ -481,6 +507,12 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags) pl + sizeof(*ip6h), 1)) goto fail; goto done; +case IPPROTO_SCTP : +if (update_flags &TCA_CSUM_UPDATE_FLAG_SCTP ) +if (!tcf_csum_sctp (skb, hl, + pl +sizeof (*ip6h))) + goto fail; + goto done;default : goto ignore_skb; }
Signature · 1 line
2.7.4
Re: [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets
Quoted 14 lines · Davide Caratti
modify
act_csumto compute crc32c on IPv4/IPv6 packets having SCTP in their payload, and extend UAPI definitions accordingly.Signed-off-by Davide Caratti <[email protected]>--- include/uapi/linux/tc_act/tc_csum.h | 3 ++- net/sched/act_csum.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)include/uapi/linux/tc_act/tc_csum.h +0
-0
include/uapi/linux/tc_act/tc_csum.h enum { · line 25
Quoted 6 lines
include/uapi/linux/tc_act/tc_csum.h +2
-1@@ -21,7 +21,8 @@ enum {TCA_CSUM_UPDATE_FLAG_IGMP =4 ,TCA_CSUM_UPDATE_FLAG_TCP =8 ,TCA_CSUM_UPDATE_FLAG_UDP =16 , -TCA_CSUM_UPDATE_FLAG_UDPLITE =32 +TCA_CSUM_UPDATE_FLAG_UDPLITE =32 , +TCA_CSUM_UPDATE_FLAG_SCTP =64
nit: please put a comma after the '64' so that the next person who adds a flag will not have to touch that line.
Quoted 7 lines
include/uapi/linux/tc_act/tc_csum.h +0
-0};struct tc_csum {net/sched/act_csum.c +0
-0
[snip]
net/sched/act_csum.c static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) · line 391
Quoted 8 lines
net/sched/act_csum.c +4
-0@@ -365,6 +385,12 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) ntohs(iph->tot_len), 1)) goto fail;break ; +case IPPROTO_SCTP : +if (update_flags &TCA_CSUM_UPDATE_FLAG_SCTP ) +if (!tcf_csum_sctp (skb, iph->ihl *4 , +ntohs (iph->tot_len)))
nit: one 'if' only?
if (update_flags & TCA_CSUM_UPDATE_FLAG_SCTP && !tcf_csum_sctp(skb, iph->ihl * 4, ntohs(iph->tot_len))
net/sched/act_csum.c static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags) · line 513
Quoted 13 lines
net/sched/act_csum.c +6
-0+ goto fail; +break ; }if (update_flags &TCA_CSUM_UPDATE_FLAG_IPV4HDR ) {@@ -481,6 +507,12 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags) pl + sizeof(*ip6h), 1)) goto fail; goto done; +case IPPROTO_SCTP : +if (update_flags &TCA_CSUM_UPDATE_FLAG_SCTP ) +if (!tcf_csum_sctp (skb, hl, + pl +sizeof (*ip6h)))
Same here.
Regards,
Nicolas
Re: [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets
Quoted 12 lines · Nicolas Dichtel
include/uapi/linux/tc_act/tc_csum.h enum { · line 25
Quoted 7 lines · Davide Caratti
include/uapi/linux/tc_act/tc_csum.h +2
-1@@ -21,7 +21,8 @@ enum { TCA_CSUM_UPDATE_FLAG_IGMP = 4, TCA_CSUM_UPDATE_FLAG_TCP = 8, TCA_CSUM_UPDATE_FLAG_UDP = 16, -TCA_CSUM_UPDATE_FLAG_UDPLITE =32 +TCA_CSUM_UPDATE_FLAG_UDPLITE =32 , + TCA_CSUM_UPDATE_FLAG_SCTP = 64nit: please put a comma after the '64' so that the next person who adds a flag
will not have to touch that line.
ok,
Quoted 11 lines
net/sched/act_csum.c static int tcf_csum_ipv4(struct sk_buff *skb, u32 · line 393
Quoted 10 lines
net/sched/act_csum.c +4
-0@@ -365,6 +385,12 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) ntohs(iph->tot_len), 1)) goto fail; break; +case IPPROTO_SCTP : +if (update_flags &TCA_CSUM_UPDATE_FLAG_SCTP ) +if (!tcf_csum_sctp (skb, iph->ihl *4 , + ntohs(iph->tot_len)))nit: one 'if' only?
Quoted 3 lines
if (update_flags & TCA_CSUM_UPDATE_FLAG_SCTP && !tcf_csum_sctp(skb, iph->ihl * 4, ntohs(iph->tot_len))
ok,
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0
-0@@ -481,6 +507,12 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags)pl +
sizeof(*ip6h), 1))
Quoted 9 lines
Quoted 7 lines
goto fail; goto done;
net/sched/act_csum.c +4
-0+case IPPROTO_SCTP : +if (update_flags &TCA_CSUM_UPDATE_FLAG_SCTP ) + if (!tcf_csum_sctp(skb, hl, + pl +
sizeof(*ip6h)))Same here.
ok,
Quoted 3 lines
Regards,
Nicolas
hello Nicolas,
thank you for the attention! I will apply the changes you suggested and repost a v2.
regards,