1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include <linux/cache.h>
- #include <linux/module.h>
- #include <linux/netdevice.h>
- #include <linux/spinlock.h>
- #include <net/protocol.h>
- const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS] __read_mostly;
- const struct net_offload __rcu *inet_offloads[MAX_INET_PROTOS] __read_mostly;
- EXPORT_SYMBOL(inet_offloads);
- int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol)
- {
- if (!prot->netns_ok) {
- pr_err("Protocol %u is not namespace aware, cannot register.\n",
- protocol);
- return -EINVAL;
- }
- return !cmpxchg((const struct net_protocol **)&inet_protos[protocol],
- NULL, prot) ? 0 : -1;
- }
- EXPORT_SYMBOL(inet_add_protocol);
- int inet_add_offload(const struct net_offload *prot, unsigned char protocol)
- {
- return !cmpxchg((const struct net_offload **)&inet_offloads[protocol],
- NULL, prot) ? 0 : -1;
- }
- EXPORT_SYMBOL(inet_add_offload);
- int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol)
- {
- int ret;
- ret = (cmpxchg((const struct net_protocol **)&inet_protos[protocol],
- prot, NULL) == prot) ? 0 : -1;
- synchronize_net();
- return ret;
- }
- EXPORT_SYMBOL(inet_del_protocol);
- int inet_del_offload(const struct net_offload *prot, unsigned char protocol)
- {
- int ret;
- ret = (cmpxchg((const struct net_offload **)&inet_offloads[protocol],
- prot, NULL) == prot) ? 0 : -1;
- synchronize_net();
- return ret;
- }
- EXPORT_SYMBOL(inet_del_offload);
|