From: Paolo Abeni <pabeni@redhat.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Willem de Bruijn <willemb@google.com>,
Steffen Klassert <steffen.klassert@secunet.com>
Subject: [RFC PATCH 1/4] net: add new helper to update an already registered offload
Date: Fri, 14 Sep 2018 17:43:21 +0200 [thread overview]
Message-ID: <ea23e244f7c4add4a9abecc647aeb43b97377200.1536939423.git.pabeni@redhat.com> (raw)
In-Reply-To: <cover.1536939423.git.pabeni@redhat.com>
This will allow us to enable/disable UDP GRO at runtime in
a later patch.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
include/net/protocol.h | 4 ++++
net/ipv4/protocol.c | 13 +++++++++----
net/ipv6/protocol.c | 13 +++++++++----
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/include/net/protocol.h b/include/net/protocol.h
index 4fc75f7ae23b..aa77e7feffab 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -104,6 +104,8 @@ extern struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS];
int inet_add_protocol(const struct net_protocol *prot, unsigned char num);
int inet_del_protocol(const struct net_protocol *prot, unsigned char num);
int inet_add_offload(const struct net_offload *prot, unsigned char num);
+int inet_update_offload(const struct net_offload *old_prot,
+ const struct net_offload *new_prot, unsigned char num);
int inet_del_offload(const struct net_offload *prot, unsigned char num);
void inet_register_protosw(struct inet_protosw *p);
void inet_unregister_protosw(struct inet_protosw *p);
@@ -115,6 +117,8 @@ int inet6_register_protosw(struct inet_protosw *p);
void inet6_unregister_protosw(struct inet_protosw *p);
#endif
int inet6_add_offload(const struct net_offload *prot, unsigned char num);
+int inet6_update_offload(const struct net_offload *old_prot,
+ const struct net_offload *new_prot, unsigned char num);
int inet6_del_offload(const struct net_offload *prot, unsigned char num);
#endif /* _PROTOCOL_H */
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c
index 32a691b7ce2c..b60f1686b918 100644
--- a/net/ipv4/protocol.c
+++ b/net/ipv4/protocol.c
@@ -65,12 +65,17 @@ int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol)
}
EXPORT_SYMBOL(inet_del_protocol);
-int inet_del_offload(const struct net_offload *prot, unsigned char protocol)
+int inet_update_offload(const struct net_offload *old_prot,
+ const struct net_offload *new_prot,
+ unsigned char protocol)
{
- int ret;
+ return (cmpxchg((const struct net_offload **)&inet_offloads[protocol],
+ old_prot, new_prot) == old_prot) ? 0 : -1;
+}
- ret = (cmpxchg((const struct net_offload **)&inet_offloads[protocol],
- prot, NULL) == prot) ? 0 : -1;
+int inet_del_offload(const struct net_offload *prot, unsigned char protocol)
+{
+ int ret = inet_update_offload(prot, NULL, protocol);
synchronize_net();
diff --git a/net/ipv6/protocol.c b/net/ipv6/protocol.c
index b5d54d4f995c..9ee6aff1f3fa 100644
--- a/net/ipv6/protocol.c
+++ b/net/ipv6/protocol.c
@@ -60,12 +60,17 @@ int inet6_add_offload(const struct net_offload *prot, unsigned char protocol)
}
EXPORT_SYMBOL(inet6_add_offload);
-int inet6_del_offload(const struct net_offload *prot, unsigned char protocol)
+int inet6_update_offload(const struct net_offload *old_prot,
+ const struct net_offload *new_prot,
+ unsigned char protocol)
{
- int ret;
+ return (cmpxchg((const struct net_offload **)&inet6_offloads[protocol],
+ old_prot, new_prot) == old_prot) ? 0 : -1;
+}
- ret = (cmpxchg((const struct net_offload **)&inet6_offloads[protocol],
- prot, NULL) == prot) ? 0 : -1;
+int inet6_del_offload(const struct net_offload *prot, unsigned char protocol)
+{
+ int ret = inet6_update_offload(prot, NULL, protocol);
synchronize_net();
--
2.17.1
next prev parent reply other threads:[~2018-09-14 20:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 15:43 [RFC PATCH 0/4] UDP: implement GRO support for UDP_SEGMENT socket Paolo Abeni
2018-09-14 15:43 ` Paolo Abeni [this message]
2018-09-14 15:43 ` [RFC PATCH 2/4] net: enable UDP gro on demand Paolo Abeni
2018-09-14 17:16 ` Willem de Bruijn
2018-09-16 18:23 ` Willem de Bruijn
2018-09-17 10:18 ` Paolo Abeni
2018-09-17 14:07 ` Willem de Bruijn
2018-09-14 15:43 ` [RFC PATCH 3/4] udp: implement GRO plain UDP sockets Paolo Abeni
2018-09-14 16:48 ` Eric Dumazet
2018-09-17 10:06 ` Paolo Abeni
2018-09-14 15:43 ` [RFC PATCH 4/4] selftests: add GRO support, fix port option processing Paolo Abeni
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=ea23e244f7c4add4a9abecc647aeb43b97377200.1536939423.git.pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=willemb@google.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).