[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ea23e244f7c4add4a9abecc647aeb43b97377200.1536939423.git.pabeni@redhat.com>
Date: Fri, 14 Sep 2018 17:43:21 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Willem de Bruijn <willemb@...gle.com>,
Steffen Klassert <steffen.klassert@...unet.com>
Subject: [RFC PATCH 1/4] net: add new helper to update an already registered offload
This will allow us to enable/disable UDP GRO at runtime in
a later patch.
Signed-off-by: Paolo Abeni <pabeni@...hat.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
Powered by blists - more mailing lists