* [PATCH net-next 0/2] net/sched: act_csum: add support for SCTP checksum
@ 2017-01-05 16:59 Davide Caratti
2017-01-05 16:59 ` [PATCH net-next 1/2] net/sched: Kconfig: select LIBCRC32C if NET_ACT_CSUM is selected Davide Caratti
2017-01-05 16:59 ` [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets Davide Caratti
0 siblings, 2 replies; 5+ messages in thread
From: Davide Caratti @ 2017-01-05 16:59 UTC (permalink / raw)
To: Jamal Hadi Salim, David S . Miller, Nicolas Dichtel; +Cc: netdev
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/2] net/sched: Kconfig: select LIBCRC32C if NET_ACT_CSUM is selected
2017-01-05 16:59 [PATCH net-next 0/2] net/sched: act_csum: add support for SCTP checksum Davide Caratti
@ 2017-01-05 16:59 ` Davide Caratti
2017-01-05 16:59 ` [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets Davide Caratti
1 sibling, 0 replies; 5+ messages in thread
From: Davide Caratti @ 2017-01-05 16:59 UTC (permalink / raw)
To: Jamal Hadi Salim, David S . Miller, Nicolas Dichtel; +Cc: netdev
LIBCRC32C is needed to compute crc32c on SCTP packets.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
net/sched/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 87956a7..a9aa38d 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -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.
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets
2017-01-05 16:59 [PATCH net-next 0/2] net/sched: act_csum: add support for SCTP checksum Davide Caratti
2017-01-05 16:59 ` [PATCH net-next 1/2] net/sched: Kconfig: select LIBCRC32C if NET_ACT_CSUM is selected Davide Caratti
@ 2017-01-05 16:59 ` Davide Caratti
2017-01-06 9:23 ` Nicolas Dichtel
1 sibling, 1 reply; 5+ messages in thread
From: Davide Caratti @ 2017-01-05 16:59 UTC (permalink / raw)
To: Jamal Hadi Salim, David S . Miller, Nicolas Dichtel; +Cc: netdev
modify act_csum to compute crc32c on IPv4/IPv6 packets having SCTP in
their payload, and extend UAPI definitions accordingly.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
include/uapi/linux/tc_act/tc_csum.h | 3 ++-
net/sched/act_csum.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/tc_act/tc_csum.h b/include/uapi/linux/tc_act/tc_csum.h
index 8ac8041..58d457f 100644
--- a/include/uapi/linux/tc_act/tc_csum.h
+++ b/include/uapi/linux/tc_act/tc_csum.h
@@ -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 {
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
index a0edd80..620ac9b 100644
--- a/net/sched/act_csum.c
+++ b/net/sched/act_csum.c
@@ -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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets
2017-01-05 16:59 ` [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets Davide Caratti
@ 2017-01-06 9:23 ` Nicolas Dichtel
2017-01-08 16:43 ` Davide Caratti
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Dichtel @ 2017-01-06 9:23 UTC (permalink / raw)
To: Davide Caratti, Jamal Hadi Salim, David S . Miller; +Cc: netdev
Le 05/01/2017 à 17:59, Davide Caratti a écrit :
> modify act_csum to compute crc32c on IPv4/IPv6 packets having SCTP in
> their payload, and extend UAPI definitions accordingly.
>
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
> ---
> include/uapi/linux/tc_act/tc_csum.h | 3 ++-
> net/sched/act_csum.c | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/tc_act/tc_csum.h b/include/uapi/linux/tc_act/tc_csum.h
> index 8ac8041..58d457f 100644
> --- a/include/uapi/linux/tc_act/tc_csum.h
> +++ b/include/uapi/linux/tc_act/tc_csum.h
> @@ -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.
> };
>
> struct tc_csum {
> diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
> index a0edd80..620ac9b 100644
> --- a/net/sched/act_csum.c
> +++ b/net/sched/act_csum.c
[snip]
> @@ -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))
> + 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets
2017-01-06 9:23 ` Nicolas Dichtel
@ 2017-01-08 16:43 ` Davide Caratti
0 siblings, 0 replies; 5+ messages in thread
From: Davide Caratti @ 2017-01-08 16:43 UTC (permalink / raw)
To: nicolas.dichtel, Jamal Hadi Salim, David S . Miller; +Cc: netdev
On Fri, 2017-01-06 at 10:23 +0100, Nicolas Dichtel wrote:
> Le 05/01/2017 à 17:59, Davide Caratti a écrit :
> > @@ -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.
>
ok,
> > @@ -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))
>
ok,
> > @@ -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.
>
ok,
>
> Regards,
> Nicolas
hello Nicolas,
thank you for the attention! I will apply the changes you suggested and
repost a v2.
regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-08 16:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-05 16:59 [PATCH net-next 0/2] net/sched: act_csum: add support for SCTP checksum Davide Caratti
2017-01-05 16:59 ` [PATCH net-next 1/2] net/sched: Kconfig: select LIBCRC32C if NET_ACT_CSUM is selected Davide Caratti
2017-01-05 16:59 ` [PATCH net-next 2/2] net/sched: act_csum: compute crc32c on SCTP packets Davide Caratti
2017-01-06 9:23 ` Nicolas Dichtel
2017-01-08 16:43 ` Davide Caratti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).