From: Davide Caratti <dcaratti@redhat.com> To: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Subject: [RFC PATCH net-next 3/5] net: introduce skb_sctp_csum_help Date: Mon, 23 Jan 2017 17:52:44 +0100 [thread overview] Message-ID: <654992ae00322bc26ab0065d0249a36d446bce97.1485177252.git.dcaratti@redhat.com> (raw) In-Reply-To: <cover.1485177252.git.dcaratti@redhat.com> skb_sctp_csum_help is like skb_checksum_help, but it is designed for checksumming SCTP packets using crc32c (see RFC3309), provided that sctp.ko has been loaded before. In case sctp.ko is not loaded, invoking skb_sctp_csum_help() on a skb results in the following printout: sk_buff: attempt to compute crc32c without sctp.ko Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: Davide Caratti <dcaratti@redhat.com> --- include/linux/netdevice.h | 1 + include/linux/skbuff.h | 3 ++- net/core/dev.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3868c32..9d72824 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3902,6 +3902,7 @@ void netdev_rss_key_fill(void *buffer, size_t len); int dev_get_nest_level(struct net_device *dev); int skb_checksum_help(struct sk_buff *skb); +int skb_sctp_csum_help(struct sk_buff *skb); struct sk_buff *__skb_gso_segment(struct sk_buff *skb, netdev_features_t features, bool tx_path); struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb, diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 44fc804..91b4e22 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -192,7 +192,8 @@ * accordingly. Note the there is no indication in the skbuff that the * CHECKSUM_PARTIAL refers to an SCTP checksum, a driver that supports * both IP checksum offload and SCTP CRC offload must verify which offload - * is configured for a packet presumably by inspecting packet headers. + * is configured for a packet presumably by inspecting packet headers; in + * case, skb_sctp_csum_help is provided to compute CRC on SCTP packets. * * NETIF_F_FCOE_CRC - This feature indicates that a device is capable of * offloading the FCOE CRC in a packet. To perform this offload the stack diff --git a/net/core/dev.c b/net/core/dev.c index 6742160..45cee84 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2554,6 +2554,29 @@ static int skb_rfc1624_csum(struct sk_buff *skb, int offset) return ret; } +/* compute 32-bit RFC3309 checksum and store it at skb->data + offset */ +static int skb_rfc3309_csum(struct sk_buff *skb, int offset) +{ + __le32 crc32c_csum; + int ret = 0; + + crc32c_csum = cpu_to_le32(~__skb_checksum(skb, offset, + skb->len - offset, ~(__u32)0, + sctp_csum_stub)); + offset += skb->csum_offset; + BUG_ON((offset + sizeof(__le32)) > skb_headlen(skb)); + + if (skb_cloned(skb) && + !skb_clone_writable(skb, offset + sizeof(__le32))) { + ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); + if (ret) + goto out; + } + *(__le32 *)(skb->data + offset) = crc32c_csum; +out: + return ret; +} + /* Invalidate hardware checksum when packet is to be mangled, and * complete checksum manually on outgoing path. * @skb - buffer that needs checksum @@ -2599,6 +2622,12 @@ int skb_checksum_help(struct sk_buff *skb) } EXPORT_SYMBOL(skb_checksum_help); +int skb_sctp_csum_help(struct sk_buff *skb) +{ + return __skb_checksum_help(skb, skb_rfc3309_csum); +} +EXPORT_SYMBOL(skb_sctp_csum_help); + __be16 skb_network_protocol(struct sk_buff *skb, int *depth) { __be16 type = skb->protocol; -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Davide Caratti <dcaratti@redhat.com> To: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Subject: [RFC PATCH net-next 3/5] net: introduce skb_sctp_csum_help Date: Mon, 23 Jan 2017 16:52:44 +0000 [thread overview] Message-ID: <654992ae00322bc26ab0065d0249a36d446bce97.1485177252.git.dcaratti@redhat.com> (raw) In-Reply-To: <cover.1485177252.git.dcaratti@redhat.com> skb_sctp_csum_help is like skb_checksum_help, but it is designed for checksumming SCTP packets using crc32c (see RFC3309), provided that sctp.ko has been loaded before. In case sctp.ko is not loaded, invoking skb_sctp_csum_help() on a skb results in the following printout: sk_buff: attempt to compute crc32c without sctp.ko Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: Davide Caratti <dcaratti@redhat.com> --- include/linux/netdevice.h | 1 + include/linux/skbuff.h | 3 ++- net/core/dev.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3868c32..9d72824 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3902,6 +3902,7 @@ void netdev_rss_key_fill(void *buffer, size_t len); int dev_get_nest_level(struct net_device *dev); int skb_checksum_help(struct sk_buff *skb); +int skb_sctp_csum_help(struct sk_buff *skb); struct sk_buff *__skb_gso_segment(struct sk_buff *skb, netdev_features_t features, bool tx_path); struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb, diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 44fc804..91b4e22 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -192,7 +192,8 @@ * accordingly. Note the there is no indication in the skbuff that the * CHECKSUM_PARTIAL refers to an SCTP checksum, a driver that supports * both IP checksum offload and SCTP CRC offload must verify which offload - * is configured for a packet presumably by inspecting packet headers. + * is configured for a packet presumably by inspecting packet headers; in + * case, skb_sctp_csum_help is provided to compute CRC on SCTP packets. * * NETIF_F_FCOE_CRC - This feature indicates that a device is capable of * offloading the FCOE CRC in a packet. To perform this offload the stack diff --git a/net/core/dev.c b/net/core/dev.c index 6742160..45cee84 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2554,6 +2554,29 @@ static int skb_rfc1624_csum(struct sk_buff *skb, int offset) return ret; } +/* compute 32-bit RFC3309 checksum and store it at skb->data + offset */ +static int skb_rfc3309_csum(struct sk_buff *skb, int offset) +{ + __le32 crc32c_csum; + int ret = 0; + + crc32c_csum = cpu_to_le32(~__skb_checksum(skb, offset, + skb->len - offset, ~(__u32)0, + sctp_csum_stub)); + offset += skb->csum_offset; + BUG_ON((offset + sizeof(__le32)) > skb_headlen(skb)); + + if (skb_cloned(skb) && + !skb_clone_writable(skb, offset + sizeof(__le32))) { + ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); + if (ret) + goto out; + } + *(__le32 *)(skb->data + offset) = crc32c_csum; +out: + return ret; +} + /* Invalidate hardware checksum when packet is to be mangled, and * complete checksum manually on outgoing path. * @skb - buffer that needs checksum @@ -2599,6 +2622,12 @@ int skb_checksum_help(struct sk_buff *skb) } EXPORT_SYMBOL(skb_checksum_help); +int skb_sctp_csum_help(struct sk_buff *skb) +{ + return __skb_checksum_help(skb, skb_rfc3309_csum); +} +EXPORT_SYMBOL(skb_sctp_csum_help); + __be16 skb_network_protocol(struct sk_buff *skb, int *depth) { __be16 type = skb->protocol; -- 2.7.4
next prev parent reply other threads:[~2017-01-23 16:59 UTC|newest] Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-01-23 16:52 [RFC PATCH net-next 0/5] net: improve support for SCTP checksums Davide Caratti 2017-01-23 16:52 ` Davide Caratti 2017-01-23 16:52 ` [RFC PATCH net-next 1/5] skbuff: add stub to help computing crc32c on SCTP packets Davide Caratti 2017-01-23 16:52 ` Davide Caratti 2017-01-23 16:52 ` [RFC PATCH net-next 2/5] net: split skb_checksum_help Davide Caratti 2017-01-23 16:52 ` Davide Caratti 2017-01-23 20:59 ` Tom Herbert 2017-01-23 20:59 ` Tom Herbert 2017-01-24 16:35 ` David Laight 2017-01-24 16:35 ` David Laight 2017-02-02 15:07 ` Davide Caratti 2017-02-02 15:07 ` Davide Caratti 2017-02-02 16:55 ` David Laight 2017-02-02 16:55 ` David Laight 2017-02-02 18:08 ` Tom Herbert 2017-02-02 18:08 ` Tom Herbert 2017-02-27 13:39 ` Davide Caratti 2017-02-27 13:39 ` Davide Caratti 2017-02-27 15:11 ` Tom Herbert 2017-02-27 15:11 ` Tom Herbert 2017-02-28 10:31 ` Davide Caratti 2017-02-28 10:31 ` Davide Caratti 2017-02-28 10:32 ` [PATCH RFC net-next v2 1/4] skbuff: add stub to help computing crc32c on SCTP packets Davide Caratti 2017-02-28 10:32 ` Davide Caratti 2017-02-28 10:32 ` [PATCH RFC net-next v2 2/4] net: introduce skb_sctp_csum_help Davide Caratti 2017-02-28 10:32 ` Davide Caratti 2017-02-28 10:32 ` [PATCH RFC net-next v2 3/4] net: more accurate checksumming in validate_xmit_skb Davide Caratti 2017-02-28 10:32 ` Davide Caratti 2017-02-28 19:50 ` Tom Herbert 2017-02-28 19:50 ` Tom Herbert 2017-02-28 10:32 ` [PATCH RFC net-next v2 4/4] Documentation: update notes on checksum offloading Davide Caratti 2017-02-28 10:32 ` Davide Caratti 2017-02-28 22:46 ` [PATCH RFC net-next v2 1/4] skbuff: add stub to help computing crc32c on SCTP packets Alexander Duyck 2017-02-28 22:46 ` Alexander Duyck 2017-03-01 3:17 ` Tom Herbert 2017-03-01 3:17 ` Tom Herbert 2017-03-01 10:53 ` David Laight 2017-03-01 10:53 ` David Laight 2017-03-06 21:51 ` Davide Caratti 2017-03-06 21:51 ` Davide Caratti 2017-03-07 18:06 ` Alexander Duyck 2017-03-07 18:06 ` Alexander Duyck 2017-03-18 13:17 ` Davide Caratti 2017-03-18 13:17 ` Davide Caratti 2017-03-18 22:35 ` Tom Herbert 2017-03-18 22:35 ` Tom Herbert 2017-04-07 14:16 ` [PATCH RFC net-next v3 0/7] improve CRC32c in the forwarding path Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 14:16 ` [PATCH RFC net-next v3 1/7] skbuff: add stub to help computing crc32c on SCTP packets Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 14:16 ` [PATCH RFC net-next v3 2/7] net: introduce skb_crc32c_csum_help Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 14:16 ` [PATCH RFC net-next v3 3/7] sk_buff: remove support for csum_bad in sk_buff Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 14:16 ` [PATCH RFC net-next v3 4/7] net: use skb->csum_algo to identify packets needing crc32c Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 15:43 ` Tom Herbert 2017-04-07 15:43 ` Tom Herbert 2017-04-07 17:29 ` Davide Caratti 2017-04-07 17:29 ` Davide Caratti 2017-04-07 18:11 ` Tom Herbert 2017-04-07 18:11 ` Tom Herbert 2017-04-13 10:36 ` Davide Caratti 2017-04-13 10:36 ` Davide Caratti 2017-04-20 13:38 ` [PATCH RFC net-next v4 0/7] net: improve support for SCTP checksums Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-20 13:38 ` [PATCH RFC net-next v4 1/7] skbuff: add stub to help computing crc32c on SCTP packets Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-20 13:38 ` [PATCH RFC net-next v4 2/7] net: introduce skb_crc32c_csum_help Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-27 12:29 ` Marcelo Ricardo Leitner 2017-04-27 12:29 ` Marcelo Ricardo Leitner 2017-04-20 13:38 ` [PATCH RFC net-next v4 3/7] sk_buff: remove support for csum_bad in sk_buff Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-27 1:34 ` [sk_buff] 95510aef27: BUG:Bad_page_state_in_process kernel test robot 2017-04-27 1:34 ` kernel test robot 2017-04-29 20:21 ` [PATCH RFC net-next v4 3/7] sk_buff: remove support for csum_bad in sk_buff Tom Herbert 2017-04-29 20:21 ` Tom Herbert 2017-04-20 13:38 ` [PATCH RFC net-next v4 4/7] net: use skb->csum_not_inet to identify packets needing crc32c Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-29 20:18 ` Tom Herbert 2017-04-29 20:18 ` Tom Herbert 2017-04-20 13:38 ` [PATCH RFC net-next v4 5/7] net: more accurate checksumming in validate_xmit_skb() Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-20 13:38 ` [PATCH RFC net-next v4 6/7] openvswitch: more accurate checksumming in queue_userspace_packet() Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-20 13:38 ` [PATCH RFC net-next v4 7/7] sk_buff.h: improve description of CHECKSUM_{COMPLETE,UNNECESSARY} Davide Caratti 2017-04-20 13:38 ` Davide Caratti 2017-04-29 20:20 ` Tom Herbert 2017-04-29 20:20 ` Tom Herbert 2017-04-27 12:41 ` [PATCH RFC net-next v4 0/7] net: improve support for SCTP checksums Marcelo Ricardo Leitner 2017-04-27 12:41 ` Marcelo Ricardo Leitner 2017-04-07 14:16 ` [PATCH RFC net-next v3 5/7] net: more accurate checksumming in validate_xmit_skb() Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 14:16 ` [PATCH RFC net-next v3 6/7] openvswitch: more accurate checksumming in queue_userspace_packet() Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-04-07 14:16 ` [PATCH RFC net-next v3 7/7] sk_buff.h: improve description of CHECKSUM_{COMPLETE,UNNECESSARY} Davide Caratti 2017-04-07 14:16 ` Davide Caratti 2017-01-23 16:52 ` Davide Caratti [this message] 2017-01-23 16:52 ` [RFC PATCH net-next 3/5] net: introduce skb_sctp_csum_help Davide Caratti 2017-01-23 16:52 ` [RFC PATCH net-next 4/5] net: more accurate checksumming in validate_xmit_skb Davide Caratti 2017-01-23 16:52 ` Davide Caratti 2017-01-23 16:52 ` [RFC PATCH net-next 5/5] Documentation: add description of skb_sctp_csum_help Davide Caratti 2017-01-23 16:52 ` Davide Caratti
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=654992ae00322bc26ab0065d0249a36d446bce97.1485177252.git.dcaratti@redhat.com \ --to=dcaratti@redhat.com \ --cc=davem@davemloft.net \ --cc=linux-sctp@vger.kernel.org \ --cc=marcelo.leitner@gmail.com \ --cc=netdev@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.