net: ILA resolver and generic resolver backend
Subsystems (6)
PATCH 6/7 net: Generic resolver backend
In reply to Tom HerbertThis patch implements the backend of a resolver, specifically it provides a means to track unresolved addresses and to time them out.
The resolver is mostly a frontend to an rhashtable where the key of the table is whatever address type or object is tracked. A resolver instance is created by net_rslv_create. A resolver is destroyed by net_rslv_destroy.
There are two functions that are used to manipulate entries in the
table: net_rslv_lookup_and_create and net_rslv_resolved.
net_rslv_lookup_and_create is called with an unresolved address as the argument. It returns a structure of type net_rslv_ent. When called a lookup is performed to see if an entry for the address is already in the table, if it is the entry is return and the false is returned in the new bool pointer argument to indicate that the entry was preexisting. If an entry is not found, one is create and true is returned on the new pointer argument. It is expected that when an entry is new the address resolution protocol is initiated (for instance a RTM_ADDR_RESOLVE message may be sent to a userspace daemon as we will do in ILA). If net_rslv_lookup_and_create returns NULL then presumably the hash table has reached the limit of number of outstanding unresolved addresses, the caller should take appropriate actions to avoid spamming the resolution protocol.
net_rslv_resolved is called when resolution is completely (e.g. ILA locator mapping was instantiated for a locator. The entry is removed for the hash table.
An argument to net_rslv_create indicates a time for the pending resolution in milliseconds. If the timer fires before resolution then the entry is removed from the table. Subsequently, another attempt to resolve the same address will result in a new entry in the table.
net_rslv_lookup_and_create allocates an net_rslv_ent struct and includes allocating related user data. This is the object[] field in the structure. The key (unresolved address) is always the first field in the the object. Following that the caller may add it's own private field data. The key length and size of the user object (including the key) are specific in net_rslv_create.
There are three callback functions that can be set as arugments in net_rslv_create:
- cmp_fn: Compare function for hash table. Arguments are the key and an object in the table. If this is NULL then the default memcmp of rhashtable is used.
- init_fn: Initial a new net_rslv_ent structure. This allows initialization of the user portion of the structure (the object[]).
- destroy_fn: Called right before a net_rslv_ent is freed. This allows cleanup of user data associated with the entry.
Note that the resolver backend only tracks unresolved addresses, it is up to the caller to perform the mechanism of resolution. This includes the possible of queuing packets awaiting resolution; this can be accomplished for instance by maintaining an skbuff queue in the net_rslv_ent user object[] data.
DOS mitigation is done by limiting the number of entries in the resolver table (the max_size which argument of net_rslv_create) and setting a timeout. IF the timeout is set then the maximum rate of new resolution requests is max_table_size / timeout. For instance, with a maximum size of 1000 entries and a timeout of 100 msecs the maximum rate of resolutions requests is 10000/s.
--- include/net/resolver.h | 58 +++++++++++ net/Kconfig | 4 + net/core/Makefile | 1 + net/core/resolver.c | 268 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 331 insertions(+) create mode 100644 include/net/resolver.h create mode 100644 net/core/resolver.c
include/net/resolver.h new file +58 -0
@@ -0,0 +1,58 @@ +#ifndef __NET_RESOLVER_H +#define __NET_RESOLVER_H + +#include <linux/rhashtable.h> + +struct net_rslv ; +struct net_rslv_ent ; + +typedef int (*net_rslv_cmpfn )(struct net_rslv *nrslv,const void *key, +const void *object); +typedef void (*net_rslv_initfn )(struct net_rslv *nrslv,void *object); +typedef void (*net_rslv_destroyfn )(struct net_rslv_ent *nrent); + +struct net_rslv { +struct rhashtable rhash_table; +struct rhashtable_params params; +net_rslv_cmpfn rslv_cmp; +net_rslv_initfn rslv_init; +net_rslv_destroyfn rslv_destroy; +size_t obj_size; +spinlock_t *locks; +unsigned int locks_mask; +unsigned int hash_rnd; +}; + +struct net_rslv_ent { +struct rcu_head rcu; +union { +/* Fields set when entry is in hash table */ +struct { +struct rhash_head node; +struct delayed_work timeout_work; +struct net_rslv *nrslv; + }; + +/* Fields set when rcu freeing structure */ +struct { +net_rslv_destroyfn destroy; + }; + }; +char object[]; +}; + +struct net_rslv *net_rslv_create (size_t size,size_t key_len, +size_t max_size, +net_rslv_cmpfn cmp_fn, +net_rslv_initfn init_fn, +net_rslv_destroyfn destroy_fn); + +struct net_rslv_ent *net_rslv_lookup_and_create (struct net_rslv *nrslv, +void *key,bool *created, +unsigned int timeout); + +void net_rslv_resolved (struct net_rslv *nrslv,void *key); + +void net_rslv_destroy (struct net_rslv *nrslv); + +#endif
net/Kconfig +4 -0
@@ -255,6 +255,10 @@ config XPS depends on SMP default y +config NET_EXT_RESOLVER + bool + default n + config HWBM bool
net/core/Makefile +1 -0
@@ -27,3 +27,4 @@ obj-$(CONFIG_LWTUNNEL) += lwtunnel.o obj-$(CONFIG_DST_CACHE) += dst_cache.o obj-$(CONFIG_HWBM) += hwbm.o obj-$(CONFIG_NET_DEVLINK) += devlink.o +obj-$(CONFIG_NET_EXT_RESOLVER) += resolver.o
net/core/resolver.c new file +268 -0
268 lines not on this page · raw message
Signature · 1 line
2.8.0.rc2
PATCH 5/7 rhashtable: abstract out function to get hash
In reply to Tom HerbertSplit out most of rht_key_hashfn which is calculating the hash into its own function. This way the hash function can be called separately to get the hash value.
--- include/linux/rhashtable.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
include/linux/rhashtable.h +18 -10
@@ -208,34 +208,42 @@ static inline unsigned int rht_bucket_index(const struct bucket_table *tbl,return (hash >>RHT_HASH_RESERVED_SPACE ) & (tbl->size -1 ); } -static inline unsigned int rht_key_hashfn ( -struct rhashtable *ht,const struct bucket_table *tbl, -const void *key,const struct rhashtable_params params) +static inline unsigned int rht_key_get_hash (struct rhashtable *ht, +const void *key,const struct rhashtable_params params, +unsigned int hash_rnd) {unsigned int hash;/* params must be equal to ht->p if it isn't constant. */ if (!__builtin_constant_p (params.key_len)) - hash = ht->p.hashfn (key, ht->key_len, tbl->hash_rnd); + hash = ht->p.hashfn (key, ht->key_len, hash_rnd);else if (params.key_len) {unsigned int key_len = params.key_len;if (params.hashfn) - hash = params.hashfn (key, key_len, tbl->hash_rnd); + hash = params.hashfn (key, key_len, hash_rnd);else if (key_len & (sizeof (u32) -1 )) - hash =jhash (key, key_len, tbl->hash_rnd); + hash =jhash (key, key_len, hash_rnd);else - hash =jhash2 (key, key_len /sizeof (u32), - tbl->hash_rnd); + hash =jhash2 (key, key_len /sizeof (u32), hash_rnd); }else {unsigned int key_len = ht->p.key_len;if (params.hashfn) - hash = params.hashfn (key, key_len, tbl->hash_rnd); + hash = params.hashfn (key, key_len, hash_rnd);else - hash =jhash (key, key_len, tbl->hash_rnd); + hash =jhash (key, key_len, hash_rnd); } +return hash; +} + +static inline unsigned int rht_key_hashfn ( +struct rhashtable *ht,const struct bucket_table *tbl, +const void *key,const struct rhashtable_params params) +{ +unsigned int hash =rht_key_get_hash (ht, key, params, tbl->hash_rnd); +return rht_bucket_index (tbl, hash); }
Signature · 1 line
2.8.0.rc2
cover net: ILA resolver and generic resolver backend
This patch set implements an ILA host side resolver. This uses LWT to implement the hook to a userspace resolver and tracks pending unresolved address using the backend net resolver.
This patch set contains:
- An new library function to allocate an array of spinlocks for use with locking hash buckets.
- Make hash function in rhashtable directly callable.
- A generic resolver backend infrastructure. This primary does two
things: track unsesolved addresses and implement a timeout for resolution not happening. These mechanisms provides rate limiting control over resolution requests (for instance in ILA it use used to rate limit requests to userspace to resolve addresses).
- The ILA resolver. This is implements to path from the kernel ILA implementation to a userspace daemon that an identifier address needs to be resolved.
- Routing messages are used over netlink to indicate resoltion requests.
Changes from intial RFC:
- Added net argument to LWT build_state
- Made resolve timeout an attribute of the LWT encap route
- Changed ILA notifications to be regular routing messages of event RTM_ADDR_RESOLVE, family RTNL_FAMILY_ILA, and group RTNLGRP_ILA_NOTIFY
Tested:
- Ran a UDP flood to random addresses in a resolver prefix. Observed timeout and limits were working (watching "ip monitor").
- Also ran against an ILA client daemon that runs the resolver protocol. Observed that when resolution completes (ILA encap route is installed) routing messages are no longer sent.
Tom Herbert (7):
lwt: Add net to build_state argument
spinlock: Add library function to allocate spinlock buckets array
rhashtable: Call library function alloc_bucket_locks
ila: Call library function alloc_bucket_locks
rhashtable: abstract out function to get hash
net: Generic resolver backend
ila: Resolver mechanism
include/linux/rhashtable.h | 28 +++-- include/linux/spinlock.h | 6 + include/net/lwtunnel.h | 10 +- include/net/resolver.h | 58 +++++++++ include/uapi/linux/ila.h | 9 ++ include/uapi/linux/lwtunnel.h | 1 + include/uapi/linux/rtnetlink.h | 8 +- lib/Makefile | 2 +- lib/bucket_locks.c | 63 ++++++++++ lib/rhashtable.c | 46 +------ net/Kconfig | 4 + net/core/Makefile | 1 + net/core/lwtunnel.c | 11 +- net/core/resolver.c | 268 +++++++++++++++++++++++++++++++++++++++++ net/ipv4/fib_semantics.c | 7 +- net/ipv4/ip_tunnel_core.c | 12 +- net/ipv6/Kconfig | 1 + net/ipv6/ila/Makefile | 2 +- net/ipv6/ila/ila.h | 16 +++ net/ipv6/ila/ila_common.c | 7 ++ net/ipv6/ila/ila_lwt.c | 15 ++- net/ipv6/ila/ila_resolver.c | 246 +++++++++++++++++++++++++++++++++++++ net/ipv6/ila/ila_xlat.c | 51 ++------ net/ipv6/route.c | 2 +- net/mpls/mpls_iptunnel.c | 6 +- 25 files changed, 761 insertions(+), 119 deletions(-) create mode 100644 include/net/resolver.h create mode 100644 lib/bucket_locks.c create mode 100644 net/core/resolver.c create mode 100644 net/ipv6/ila/ila_resolver.c
Signature · 1 line
2.8.0.rc2
PATCH 2/7 spinlock: Add library function to allocate spinlock buckets array
Add two new library functions alloc_bucket_spinlocks and free_bucket_spinlocks. These are use to allocate and free an array of spinlocks that are useful as locks for hash buckets. The interface specifies the maximum number of spinlocks in the array as well as a CPU multiplier to derive the number of spinlocks to allocate. The number to allocated is rounded up to a power of two to make the array amenable to hash lookup.
Reviewed by Greg Rose <[email protected]>
--- include/linux/spinlock.h | 6 +++++ lib/Makefile | 2 +- lib/bucket_locks.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 lib/bucket_locks.c
include/linux/spinlock.h +6 -0
@@ -416,4 +416,10 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);#define atomic_dec_and_lock (atomic, lock) \ __cond_lock(lock, _atomic_dec_and_lock(atomic, lock)) +int alloc_bucket_spinlocks (spinlock_t **locks,unsigned int *lock_mask, +unsigned int max_size,unsigned int cpu_mult, +gfp_t gfp); + +void free_bucket_spinlocks (spinlock_t *locks); +#endif /* __LINUX_SPINLOCK_H */
lib/Makefile +1 -1
@@ -36,7 +36,7 @@ obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ gcd.o lcm.o list_sort.o uuid.o flex_array.o iov_iter.o clz_ctz.o \ bsearch.o find_bit.o llist.o memweight.o kfifo.o \ percpu-refcount.o percpu_ida.o rhashtable.o reciprocal_div.o \ - once.o + once.o bucket_locks.o obj-y += string_helpers.o obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o obj-y += hexdump.o
lib/bucket_locks.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.8.0.rc2
PATCH 4/7 ila: Call library function alloc_bucket_locks
In reply to Tom HerbertTo allocate the array of bucket locks for the hash table we now call library function alloc_bucket_spinlocks.
--- net/ipv6/ila/ila_xlat.c | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-)
net/ipv6/ila/ila_xlat.c +5 -31
@@ -30,34 +30,6 @@ struct ila_net {bool hooks_registered; }; -#define LOCKS_PER_CPU 10 - -static int alloc_ila_locks (struct ila_net *ilan) -{ -unsigned int i, size; -unsigned int nr_pcpus =num_possible_cpus (); - - nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL); - size =roundup_pow_of_two (nr_pcpus *LOCKS_PER_CPU ); - -if (sizeof (spinlock_t) !=0 ) { -#ifdef CONFIG_NUMA -if (size *sizeof (spinlock_t) >PAGE_SIZE ) - ilan->locks =vmalloc (size *sizeof (spinlock_t)); - else -#endif - ilan->locks =kmalloc_array (size,sizeof (spinlock_t), -GFP_KERNEL ); -if (!ilan->locks) -return -ENOMEM ; -for (i =0 ; i < size; i++) -spin_lock_init (&ilan->locks[i]); - } - ilan->locks_mask = size -1 ; - -return 0 ; -} -static u32 hashrnd__read_mostly ; static __always_inline void __ila_hash_secret_init(void) {
@@ -561,14 +533,16 @@ static const struct genl_ops ila_nl_ops[] = { }, }; -#define ILA_HASH_TABLE_SIZE 1024 +#define LOCKS_PER_CPU 10 +#define MAX_LOCKS 1024static __net_init int ila_init_net (struct net *net) {int err;struct ila_net *ilan =net_generic (net, ila_net_id); - err =alloc_ila_locks (ilan); + err =alloc_bucket_spinlocks (&ilan->locks, &ilan->locks_mask, +MAX_LOCKS ,LOCKS_PER_CPU ,GFP_KERNEL );if (err)return err;
@@ -583,7 +557,7 @@ static __net_exit void ila_exit_net(struct net *net)rhashtable_free_and_destroy (&ilan->rhash_table, ila_free_cb,NULL ); -kvfree (ilan->locks); +free_bucket_spinlocks (ilan->locks);if (ilan->hooks_registered) nf_unregister_net_hooks(net, ila_nf_hook_ops,
Signature · 1 line
2.8.0.rc2
PATCH 1/7 lwt: Add net to build_state argument
In reply to Tom HerbertUsers of LWT need to know net if they want to have per net operations in LWT.
--- include/net/lwtunnel.h | 10 +++++----- net/core/lwtunnel.c | 11 +++++++---- net/ipv4/fib_semantics.c | 7 ++++--- net/ipv4/ip_tunnel_core.c | 12 ++++++------ net/ipv6/ila/ila_lwt.c | 6 +++--- net/ipv6/route.c | 2 +- net/mpls/mpls_iptunnel.c | 6 +++--- 7 files changed, 29 insertions(+), 25 deletions(-)
include/net/lwtunnel.h +5 -5
@@ -33,9 +33,9 @@ struct lwtunnel_state { };struct lwtunnel_encap_ops { -int (*build_state)(struct net_device *dev,struct nlattr *encap, -unsigned int family,const void *cfg, -struct lwtunnel_state **ts); +int (*build_state)(struct net *net,struct net_device *dev, +struct nlattr *encap,unsigned int family, +const void *cfg,struct lwtunnel_state **ts);int (*output)(struct net *net,struct sock *sk,struct sk_buff *skb);int (*input)(struct sk_buff *skb); int (*fill_encap)(struct sk_buff *skb,
@@ -106,8 +106,8 @@ int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op, unsigned int num);int lwtunnel_encap_del_ops (const struct lwtunnel_encap_ops *op,unsigned int num); -int lwtunnel_build_state (struct net_device *dev,u16 encap_type, -struct nlattr *encap, +int lwtunnel_build_state (struct net *net,struct net_device *dev, +u16 encap_type,struct nlattr *encap,unsigned int family,const void *cfg,struct lwtunnel_state **lws); int lwtunnel_fill_encap(struct sk_buff *skb,
net/core/lwtunnel.c +7 -4
@@ -39,6 +39,8 @@ static const char *lwtunnel_encap_str(enum lwtunnel_encap_types encap_type)return "MPLS" ;case LWTUNNEL_ENCAP_ILA :return "ILA" ; +case LWTUNNEL_ENCAP_ILA_NOTIFY : +return "ILA_NOTIFY" ;case LWTUNNEL_ENCAP_IP6 :case LWTUNNEL_ENCAP_IP :case LWTUNNEL_ENCAP_NONE :
@@ -96,9 +98,10 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *ops, }EXPORT_SYMBOL (lwtunnel_encap_del_ops); -int lwtunnel_build_state (struct net_device *dev,u16 encap_type, -struct nlattr *encap,unsigned int family, -const void *cfg,struct lwtunnel_state **lws) +int lwtunnel_build_state (struct net *net,struct net_device *dev, +u16 encap_type,struct nlattr *encap, +unsigned int family,const void *cfg, +struct lwtunnel_state **lws) {const struct lwtunnel_encap_ops *ops;int ret = -EINVAL ;
@@ -123,7 +126,7 @@ int lwtunnel_build_state(struct net_device *dev, u16 encap_type, }#endif if (likely (ops && ops->build_state)) - ret = ops->build_state (dev, encap, family, cfg, lws); + ret = ops->build_state (net, dev, encap, family, cfg, lws);rcu_read_unlock ();return ret;
net/ipv4/fib_semantics.c +4 -3
@@ -511,7 +511,8 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, goto err_inval;if (cfg->fc_oif) dev =__dev_get_by_index (net, cfg->fc_oif); - ret =lwtunnel_build_state (dev,nla_get_u16 ( + ret =lwtunnel_build_state (net, dev, +nla_get_u16 ( nla_entype), nla,AF_INET , cfg, &lwtstate);
@@ -610,7 +611,7 @@ static int fib_encap_match(struct net *net, u16 encap_type,if (oif) dev =__dev_get_by_index (net, oif); - ret =lwtunnel_build_state (dev, encap_type, encap, + ret =lwtunnel_build_state (net, dev, encap_type, encap,AF_INET , cfg, &lwtstate);if (!ret) { result =lwtunnel_cmp_encap (lwtstate, nh->nh_lwtstate);
@@ -1098,7 +1099,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) goto err_inval;if (cfg->fc_oif) dev =__dev_get_by_index (net, cfg->fc_oif); - err =lwtunnel_build_state (dev, cfg->fc_encap_type, + err =lwtunnel_build_state (net, dev, cfg->fc_encap_type, cfg->fc_encap,AF_INET , cfg, &lwtstate);if (err)
net/ipv4/ip_tunnel_core.c +6 -6
@@ -239,9 +239,9 @@ static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = { [LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 }, }; -static int ip_tun_build_state (struct net_device *dev,struct nlattr *attr, -unsigned int family,const void *cfg, -struct lwtunnel_state **ts) +static int ip_tun_build_state (struct net *net,struct net_device *dev, +struct nlattr *attr,unsigned int family, +const void *cfg,struct lwtunnel_state **ts) {struct ip_tunnel_info *tun_info;struct lwtunnel_state *new_state;
@@ -335,9 +335,9 @@ static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = { [LWTUNNEL_IP6_FLAGS] = { .type = NLA_U16 }, }; -static int ip6_tun_build_state (struct net_device *dev,struct nlattr *attr, -unsigned int family,const void *cfg, -struct lwtunnel_state **ts) +static int ip6_tun_build_state (struct net *net,struct net_device *dev, +struct nlattr *attr,unsigned int family, +const void *cfg,struct lwtunnel_state **ts) {struct ip_tunnel_info *tun_info;struct lwtunnel_state *new_state;
net/ipv6/ila/ila_lwt.c +3 -3
@@ -56,9 +56,9 @@ static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = { [ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, }, }; -static int ila_build_state (struct net_device *dev,struct nlattr *nla, -unsigned int family,const void *cfg, -struct lwtunnel_state **ts) +static int ila_build_state (struct net *net,struct net_device *dev, +struct nlattr *nla,unsigned int family, +const void *cfg,struct lwtunnel_state **ts) {struct ila_params *p;struct nlattr *tb[ILA_ATTR_MAX +1 ];
net/ipv6/route.c +1 -1
@@ -1884,7 +1884,7 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg)if (cfg->fc_encap) {struct lwtunnel_state *lwtstate; - err =lwtunnel_build_state (dev, cfg->fc_encap_type, + err =lwtunnel_build_state (net, dev, cfg->fc_encap_type, cfg->fc_encap,AF_INET6 , cfg, &lwtstate);if (err)
net/mpls/mpls_iptunnel.c +3 -3
@@ -126,9 +126,9 @@ drop:return -EINVAL ; } -static int mpls_build_state (struct net_device *dev,struct nlattr *nla, -unsigned int family,const void *cfg, -struct lwtunnel_state **ts) +static int mpls_build_state (struct net *net,struct net_device *dev, +struct nlattr *nla,unsigned int family, +const void *cfg,struct lwtunnel_state **ts) {struct mpls_iptunnel_encap *tun_encap_info;struct nlattr *tb[MPLS_IPTUNNEL_MAX +1 ];
Signature · 1 line
2.8.0.rc2
PATCH 3/7 rhashtable: Call library function alloc_bucket_locks
In reply to Tom HerbertTo allocate the array of bucket locks for the hash table we now call library function alloc_bucket_spinlocks. This function is based on the old alloc_bucket_locks in rhashtable and should produce the same effect.
--- lib/rhashtable.c | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-)
lib/rhashtable.c +4 -42
@@ -59,50 +59,10 @@ EXPORT_SYMBOL_GPL(lockdep_rht_bucket_is_held);#define ASSERT_RHT_MUTEX (HT )#endif - -static int alloc_bucket_locks (struct rhashtable *ht,struct bucket_table *tbl, -gfp_t gfp) -{ -unsigned int i, size; -#if defined(CONFIG_PROVE_LOCKING ) -unsigned int nr_pcpus =2 ; -#else -unsigned int nr_pcpus =num_possible_cpus (); -#endif - - nr_pcpus = min_t(unsigned int, nr_pcpus, 64UL); - size =roundup_pow_of_two (nr_pcpus * ht->p.locks_mul); - -/* Never allocate more than 0.5 locks per bucket */ - size = min_t(unsigned int, size, tbl->size >> 1); - -if (sizeof (spinlock_t) !=0 ) { - tbl->locks =NULL ; -#ifdef CONFIG_NUMA -if (size *sizeof (spinlock_t) >PAGE_SIZE && - gfp ==GFP_KERNEL ) - tbl->locks =vmalloc (size *sizeof (spinlock_t)); -#endif -if (gfp !=GFP_KERNEL ) - gfp |= __GFP_NOWARN | __GFP_NORETRY; - -if (!tbl->locks) - tbl->locks =kmalloc_array (size,sizeof (spinlock_t), - gfp); -if (!tbl->locks) -return -ENOMEM ; -for (i =0 ; i < size; i++) -spin_lock_init (&tbl->locks[i]); - } - tbl->locks_mask = size -1 ; - -return 0 ; -} -static void bucket_table_free (const struct bucket_table *tbl) {if (tbl) -kvfree (tbl->locks); +free_bucket_spinlocks (tbl->locks);kvfree (tbl); }
@@ -131,7 +91,9 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, tbl->size = nbuckets; -if (alloc_bucket_locks (ht, tbl, gfp) <0 ) { +/* Never allocate more than 0.5 locks per bucket */ +if (alloc_bucket_spinlocks (&tbl->locks, &tbl->locks_mask, + tbl->size >>1 , ht->p.locks_mul, gfp)) {bucket_table_free (tbl);return NULL ; }
Signature · 1 line
2.8.0.rc2
PATCH 7/7 ila: Resolver mechanism
In reply to Tom HerbertImplement an ILA resolver. This uses LWT to implement the hook to a userspace resolver and tracks pending unresolved address using the backend net resolver.
The idea is that the kernel sets an ILA resolver route to the SIR prefix, something like:
ip route add 3333::/64 encap ila-resolve \
via 2401:db00:20:911a::27:0 dev eth0When a packet hits the route the address is looked up in a resolver table. If the entry is created (no entry with the address already exists) then an rtnl message is generated with group RTNLGRP_ILA_NOTIFY and type RTM_ADDR_RESOLVE. A userspace daemon can listen for such messages and perform an ILA resolution protocol to determine the ILA mapping. If the mapping is resolved then a /128 ila encap router is set so that host can perform ILA translation and send directly to destination.
--- include/uapi/linux/ila.h | 9 ++ include/uapi/linux/lwtunnel.h | 1 + include/uapi/linux/rtnetlink.h | 8 +- net/ipv6/Kconfig | 1 + net/ipv6/ila/Makefile | 2 +- net/ipv6/ila/ila.h | 16 +++ net/ipv6/ila/ila_common.c | 7 ++ net/ipv6/ila/ila_lwt.c | 9 ++ net/ipv6/ila/ila_resolver.c | 246 +++++++++++++++++++++++++++++++++++++++++ net/ipv6/ila/ila_xlat.c | 15 ++- 10 files changed, 304 insertions(+), 10 deletions(-) create mode 100644 net/ipv6/ila/ila_resolver.c
include/uapi/linux/ila.h +9 -0
@@ -42,4 +42,13 @@ enum { ILA_CSUM_NO_ACTION, }; +enum { +ILA_NOTIFY_ATTR_UNSPEC , +ILA_NOTIFY_ATTR_TIMEOUT ,/* u32 */ + + __ILA_NOTIFY_ATTR_MAX, +}; + +#define ILA_NOTIFY_ATTR_MAX (__ILA_NOTIFY_ATTR_MAX - 1) +#endif /* _UAPI_LINUX_ILA_H */
include/uapi/linux/lwtunnel.h +1 -0
@@ -9,6 +9,7 @@ enum lwtunnel_encap_types {LWTUNNEL_ENCAP_IP ,LWTUNNEL_ENCAP_ILA ,LWTUNNEL_ENCAP_IP6 , +LWTUNNEL_ENCAP_ILA_NOTIFY , __LWTUNNEL_ENCAP_MAX, };
include/uapi/linux/rtnetlink.h +7 -1
@@ -12,7 +12,8 @@*/ #define RTNL_FAMILY_IPMR 128#define RTNL_FAMILY_IP6MR 129 -#define RTNL_FAMILY_MAX 129 +#define RTNL_FAMILY_ILA 130 +#define RTNL_FAMILY_MAX 130/**** * Routing/neighbour discovery messages.
@@ -144,6 +145,9 @@ enum { RTM_GETSTATS = 94,#define RTM_GETSTATS RTM_GETSTATS + RTM_ADDR_RESOLVE = 95, +#define RTM_ADDR_RESOLVE RTM_ADDR_RESOLVE + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
@@ -656,6 +660,8 @@ enum rtnetlink_groups {#define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE RTNLGRP_NSID,#define RTNLGRP_NSID RTNLGRP_NSID + RTNLGRP_ILA_NOTIFY, +#define RTNLGRP_ILA_NOTIFY RTNLGRP_ILA_NOTIFY __RTNLGRP_MAX };#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
net/ipv6/Kconfig +1 -0
@@ -97,6 +97,7 @@ config IPV6_ILA tristate "IPv6: Identifier Locator Addressing (ILA)" depends on NETFILTER select LWTUNNEL + select NET_EXT_RESOLVER ---help--- Support for IPv6 Identifier Locator Addressing (ILA).
net/ipv6/ila/Makefile +1 -1
@@ -4,4 +4,4 @@ obj-$(CONFIG_IPV6_ILA) += ila.o -ila-objs := ila_common.o ila_lwt.o ila_xlat.o +ila-objs := ila_common.o ila_lwt.o ila_xlat.o ila_resolver.o
net/ipv6/ila/ila.h +16 -0
@@ -15,6 +15,7 @@#include <linux/ip.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/rhashtable.h> #include <linux/socket.h> #include <linux/skbuff.h> #include <linux/types.h>
@@ -23,6 +24,16 @@#include <net/protocol.h> #include <uapi/linux/ila.h> +extern unsigned int ila_net_id; + +struct ila_net { +struct rhashtable rhash_table; +spinlock_t *locks;/* Bucket locks for entry manipulation */ +unsigned int locks_mask; +bool hooks_registered; +struct net_rslv *nrslv; +}; + struct ila_locator { union { __u8 v8[8];
@@ -114,9 +125,14 @@ void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p,void ila_init_saved_csum (struct ila_params *p); +void ila_rslv_resolved (struct ila_net *ilan,struct ila_addr *iaddr);int ila_lwt_init (void );void ila_lwt_fini (void );int ila_xlat_init (void );void ila_xlat_fini (void ); +int ila_rslv_init (void ); +void ila_rslv_fini (void ); +int ila_init_resolver_net (struct ila_net *ilan); +void ila_exit_resolver_net (struct ila_net *ilan);#endif /* __ILA_H */
net/ipv6/ila/ila_common.c +7 -0
@@ -157,7 +157,13 @@ static int __init ila_init(void)if (ret) goto fail_xlat; + ret =ila_rslv_init (); +if (ret) + goto fail_rslv; +return 0 ; +fail_rslv: +ila_xlat_fini (); fail_xlat:ila_lwt_fini (); fail_lwt:
@@ -168,6 +174,7 @@ static void __exit ila_fini(void) {ila_xlat_fini ();ila_lwt_fini (); +ila_rslv_fini (); }module_init (ila_init);
net/ipv6/ila/ila_lwt.c +9 -0
@@ -9,6 +9,7 @@#include <net/ip.h> #include <net/ip6_fib.h> #include <net/lwtunnel.h> +#include <net/netns/generic.h> #include <net/protocol.h> #include <uapi/linux/ila.h> #include "ila.h"
@@ -122,6 +123,14 @@ static int ila_build_state(struct net *net, struct net_device *dev, *ts = newts; +if (cfg6->fc_dst_len >=sizeof (struct ila_addr )) { +struct net *net =dev_net (dev); +struct ila_net *ilan =net_generic (net, ila_net_id); + +/* Cancel any pending resolution on this address */ +ila_rslv_resolved (ilan, iaddr); + } +return 0 ; }
net/ipv6/ila/ila_resolver.c new file +246 -0
246 lines not on this page · raw message
net/ipv6/ila/ila_xlat.c +7 -8
@@ -21,14 +21,7 @@ struct ila_map {struct rcu_head rcu; }; -static unsigned int ila_net_id; - -struct ila_net { -struct rhashtable rhash_table; -spinlock_t *locks;/* Bucket locks for entry manipulation */ -unsigned int locks_mask; -bool hooks_registered; -}; +unsigned int ila_net_id;static u32 hashrnd__read_mostly ; static __always_inline void __ila_hash_secret_init(void)
@@ -546,6 +539,10 @@ static __net_init int ila_init_net(struct net *net)if (err)return err; +/* Resolver net is created on demand when LWT ILA resolver route +* is made. +*/ +rhashtable_init (&ilan->rhash_table, &rht_params);return 0 ;
@@ -557,6 +554,8 @@ static __net_exit void ila_exit_net(struct net *net)rhashtable_free_and_destroy (&ilan->rhash_table, ila_free_cb,NULL ); +ila_exit_resolver_net (ilan); +free_bucket_spinlocks (ilan->locks);if (ilan->hooks_registered)
Signature · 1 line
2.8.0.rc2
kbuild test robot
build botRe: [PATCH net-next 1/7] lwt: Add net to build_state argument
In reply to Tom Herberturl: https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357 config: x86_64-randconfig-x013-201637 (attached as .config) compiler: gcc-6…
Hi Tom,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357
config: x86_64-randconfig-x013-201637 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All error/warnings (new ones prefixed by >>):
net/ipv4/fib_semantics.c: In function 'fib_get_nhs':
>> net/ipv4/fib_semantics.c:514:32: error: passing argument 1 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
ret = lwtunnel_build_state(net, dev,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct net_device *' but argument is of type 'struct net *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
>> net/ipv4/fib_semantics.c:514:37: warning: passing argument 2 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
ret = lwtunnel_build_state(net, dev,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'u16 {aka short unsigned int}' but argument is of type 'struct net_device *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
>> net/ipv4/fib_semantics.c:515:11: warning: passing argument 3 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
nla_get_u16(
^~~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct nlattr *' but argument is of type 'u16 {aka short unsigned int}'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:517:11: warning: passing argument 4 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
nla, AF_INET, cfg,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'unsigned int' but argument is of type 'struct nlattr *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:23:0:
>> include/linux/socket.h:163:18: warning: passing argument 5 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
#define AF_INET 2 /* Internet IP Protocol */
^
>> net/ipv4/fib_semantics.c:517:17: note: in expansion of macro 'AF_INET'
nla, AF_INET, cfg,
^~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'const void *' but argument is of type 'int'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:517:26: error: passing argument 6 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
nla, AF_INET, cfg,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct lwtunnel_state **' but argument is of type 'struct fib_config *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
>> net/ipv4/fib_semantics.c:514:11: error: too many arguments to function 'lwtunnel_build_state'
ret = lwtunnel_build_state(net, dev,
^~~~~~~~~~~~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: declared here
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c: In function 'fib_encap_match':
net/ipv4/fib_semantics.c:614:29: error: passing argument 1 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct net_device *' but argument is of type 'struct net *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:614:34: warning: passing argument 2 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'u16 {aka short unsigned int}' but argument is of type 'struct net_device *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:614:39: warning: passing argument 3 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct nlattr *' but argument is of type 'u16 {aka short unsigned int}'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:614:51: warning: passing argument 4 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'unsigned int' but argument is of type 'struct nlattr *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:23:0:
>> include/linux/socket.h:163:18: warning: passing argument 5 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
#define AF_INET 2 /* Internet IP Protocol */
^
net/ipv4/fib_semantics.c:615:8: note: in expansion of macro 'AF_INET'
AF_INET, cfg, &lwtstate);
^~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'const void *' but argument is of type 'int'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:615:17: error: passing argument 6 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
AF_INET, cfg, &lwtstate);
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct lwtunnel_state **' but argument is of type 'const struct fib_config *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:614:8: error: too many arguments to function 'lwtunnel_build_state'
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^~~~~~~~~~~~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: declared here
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c: In function 'fib_create_info':
net/ipv4/fib_semantics.c:1102:31: error: passing argument 1 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct net_device *' but argument is of type 'struct net *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:1102:36: warning: passing argument 2 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'u16 {aka short unsigned int}' but argument is of type 'struct net_device *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:1102:41: warning: passing argument 3 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct nlattr *' but argument is of type 'u16 {aka short unsigned int}'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:1103:10: warning: passing argument 4 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
cfg->fc_encap, AF_INET, cfg,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'unsigned int' but argument is of type 'struct nlattr *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
In file included from net/ipv4/fib_semantics.c:23:0:
>> include/linux/socket.h:163:18: warning: passing argument 5 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
#define AF_INET 2 /* Internet IP Protocol */
^
net/ipv4/fib_semantics.c:1103:25: note: in expansion of macro 'AF_INET'
cfg->fc_encap, AF_INET, cfg,
^~~~~~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'const void *' but argument is of type 'int'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:1103:34: error: passing argument 6 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
cfg->fc_encap, AF_INET, cfg,
^~~
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct lwtunnel_state **' but argument is of type 'struct fib_config *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv4/fib_semantics.c:1102:10: error: too many arguments to function 'lwtunnel_build_state'
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~~~~~~~~~~~~~~~~~~ In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: declared here
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
net/ipv6/route.c: In function 'ip6_route_info_create':
>> net/ipv6/route.c:1887:30: error: passing argument 1 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57:
include/net/lwtunnel.h:172:19: note: expected 'struct net_device *' but argument is of type 'struct net *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
>> net/ipv6/route.c:1887:35: warning: passing argument 2 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57:
include/net/lwtunnel.h:172:19: note: expected 'u16 {aka short unsigned int}' but argument is of type 'struct net_device *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
>> net/ipv6/route.c:1887:40: warning: passing argument 3 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57:
include/net/lwtunnel.h:172:19: note: expected 'struct nlattr *' but argument is of type 'u16 {aka short unsigned int}'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:1888:9: warning: passing argument 4 of 'lwtunnel_build_state' makes integer from pointer without a cast [-Wint-conversion]
cfg->fc_encap, AF_INET6, cfg,
^~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57:
include/net/lwtunnel.h:172:19: note: expected 'unsigned int' but argument is of type 'struct nlattr *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
In file included from net/ipv6/route.c:34:0:
include/linux/socket.h:171:18: warning: passing argument 5 of 'lwtunnel_build_state' makes pointer from integer without a cast [-Wint-conversion]
#define AF_INET6 10 /* IP version 6 */
^
>> net/ipv6/route.c:1888:24: note: in expansion of macro 'AF_INET6'
cfg->fc_encap, AF_INET6, cfg,
^~~~~~~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57:
include/net/lwtunnel.h:172:19: note: expected 'const void *' but argument is of type 'int'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:1888:34: error: passing argument 6 of 'lwtunnel_build_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
cfg->fc_encap, AF_INET6, cfg,
^~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57:
include/net/lwtunnel.h:172:19: note: expected 'struct lwtunnel_state **' but argument is of type 'struct fib6_config *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
>> net/ipv6/route.c:1887:9: error: too many arguments to function 'lwtunnel_build_state'
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^~~~~~~~~~~~~~~~~~~~
In file included from include/net/ip_tunnels.h:17:0,
from include/net/dst_metadata.h:5,
from net/ipv6/route.c:57: include/net/lwtunnel.h:172:19: note: declared here
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/lwtunnel_build_state +514 net/ipv4/fib_semantics.c
508 nla_entype = nla_find(attrs, attrlen,
509 RTA_ENCAP_TYPE);
510 if (!nla_entype)
511 goto err_inval;
512 if (cfg->fc_oif)
513 dev = __dev_get_by_index(net, cfg->fc_oif);
> 514 ret = lwtunnel_build_state(net, dev, > 515 nla_get_u16( 516 nla_entype), > 517 nla, AF_INET, cfg, 518 &lwtstate);
519 if (ret)
520 goto errout;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH net-next 1/7] lwt: Add net to build_state argument
In reply to Tom Herberturl: https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357 config: i386-randconfig-x003-201637 (attached as .config) compiler: gcc-6…
Hi Tom,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357
config: i386-randconfig-x003-201637 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 Note: the linux-review/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357 HEAD ef54da9d3e09732810a23f283e0f8039fb18eede builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
net/core/lwtunnel.c: In function 'lwtunnel_encap_str':
>> net/core/lwtunnel.c:42:7: error: 'LWTUNNEL_ENCAP_ILA_NOTIFY' undeclared (first use in this function)
case LWTUNNEL_ENCAP_ILA_NOTIFY:
^~~~~~~~~~~~~~~~~~~~~~~~~ net/core/lwtunnel.c:42:7: note: each undeclared identifier is reported only once for each function it appears in
vim +/LWTUNNEL_ENCAP_ILA_NOTIFY +42 net/core/lwtunnel.c
36 */
37 switch (encap_type) {
38 case LWTUNNEL_ENCAP_MPLS:
39 return "MPLS";
40 case LWTUNNEL_ENCAP_ILA:
41 return "ILA";
> 42 case LWTUNNEL_ENCAP_ILA_NOTIFY:
43 return "ILA_NOTIFY";
44 case LWTUNNEL_ENCAP_IP6:
45 case LWTUNNEL_ENCAP_IP:---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH net-next 1/7] lwt: Add net to build_state argument
In reply to Tom Herberturl: https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357 config: microblaze-mmu_defconfig (attached as .config) compiler…
Hi Tom,
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-resolver-and-generic-resolver-backend/20160915-073357
config: microblaze-mmu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 4.9.0
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=microblaze
All warnings (new ones prefixed by >>):
net/ipv4/fib_semantics.c: In function 'fib_encap_match':
>> net/ipv4/fib_semantics.c:614:8: warning: passing argument 1 of 'lwtunnel_build_state' from incompatible pointer type
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct net_device *' but argument is of type 'struct net *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:614:8: warning: passing argument 2 of 'lwtunnel_build_state' makes integer from pointer without a cast
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'u16' but argument is of type 'struct net_device *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:614:8: warning: passing argument 3 of 'lwtunnel_build_state' makes pointer from integer without a cast
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct nlattr *' but argument is of type 'u16'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:614:8: warning: passing argument 4 of 'lwtunnel_build_state' makes integer from pointer without a cast
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'unsigned int' but argument is of type 'struct nlattr *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:614:8: warning: passing argument 5 of 'lwtunnel_build_state' makes pointer from integer without a cast
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'const void *' but argument is of type 'int'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:614:8: warning: passing argument 6 of 'lwtunnel_build_state' from incompatible pointer type
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct lwtunnel_state **' but argument is of type 'const struct fib_config *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:614:8: error: too many arguments to function 'lwtunnel_build_state'
ret = lwtunnel_build_state(net, dev, encap_type, encap,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: declared here
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c: In function 'fib_create_info':
net/ipv4/fib_semantics.c:1102:10: warning: passing argument 1 of 'lwtunnel_build_state' from incompatible pointer type
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct net_device *' but argument is of type 'struct net *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:1102:10: warning: passing argument 2 of 'lwtunnel_build_state' makes integer from pointer without a cast
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'u16' but argument is of type 'struct net_device *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:1102:10: warning: passing argument 3 of 'lwtunnel_build_state' makes pointer from integer without a cast
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct nlattr *' but argument is of type 'u16'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:1102:10: warning: passing argument 4 of 'lwtunnel_build_state' makes integer from pointer without a cast
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'unsigned int' but argument is of type 'struct nlattr *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:1102:10: warning: passing argument 5 of 'lwtunnel_build_state' makes pointer from integer without a cast
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'const void *' but argument is of type 'int'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:1102:10: warning: passing argument 6 of 'lwtunnel_build_state' from incompatible pointer type
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^
In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: expected 'struct lwtunnel_state **' but argument is of type 'struct fib_config *'
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
net/ipv4/fib_semantics.c:1102:10: error: too many arguments to function 'lwtunnel_build_state'
err = lwtunnel_build_state(net, dev, cfg->fc_encap_type,
^ In file included from net/ipv4/fib_semantics.c:45:0:
include/net/lwtunnel.h:172:19: note: declared here
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
^
vim +/lwtunnel_build_state +614 net/ipv4/fib_semantics.c
598 #endif /* CONFIG_IP_ROUTE_MULTIPATH */
599
600 static int fib_encap_match(struct net *net, u16 encap_type,
601 struct nlattr *encap,
602 int oif, const struct fib_nh *nh,
603 const struct fib_config *cfg)
604 {
605 struct lwtunnel_state *lwtstate;
606 struct net_device *dev = NULL;
607 int ret, result = 0;
608
609 if (encap_type == LWTUNNEL_ENCAP_NONE)
610 return 0;
611
612 if (oif)
613 dev = __dev_get_by_index(net, oif);
> 614 ret = lwtunnel_build_state(net, dev, encap_type, encap, 615 AF_INET, cfg, &lwtstate);
616 if (!ret) {
617 result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate);
618 lwtstate_free(lwtstate);
619 }
620
621 return result;
622 }
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH net-next 1/7] lwt: Add net to build_state argument
In reply to Tom HerbertQuoted 6 lines · Tom Herbert
Users of LWT need to know net if they want to have per net operations in LWT.
Signed-off-by Tom Herbert <[email protected]>---
Re: [PATCH net-next 3/7] rhashtable: Call library function alloc_bucket_locks
In reply to Tom HerbertQuoted 7 lines · Tom Herbert
To allocate the array of bucket locks for the hash table we now call library function
alloc_bucket_spinlocks. This function is based on the oldalloc_bucket_locksin rhashtable and should produce the same effect.Acked-by Thomas Graf <[email protected]>Signed-off-by Tom Herbert <[email protected]>
On second thought when I do the nested allocation I could simply restore this function. So
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerRe: [PATCH net-next 5/7] rhashtable: abstract out function to get hash
In reply to Tom HerbertQuoted 6 lines · Tom Herbert
Split out most of
rht_key_hashfnwhich is calculating the hash into its own function. This way the hash function can be called separately to get the hash value.Acked-by Thomas Graf <[email protected]>Signed-off-by Tom Herbert <[email protected]>
I don't get this one. You're just using jhash, right? Why not call jhash directly instead of rht_get_key_hashfn?
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerRe: [PATCH net-next 6/7] net: Generic resolver backend
In reply to Tom Herbertnet/core/resolver.c line 222
Quoted 8 lines · Tom Herbert
net/core/resolver.c new file +7
-0+ nrslv->params.head_offset = offsetof(struct net_rslv_ent , node); + nrslv->params.key_offset = offsetof(struct net_rslv_ent , object); + nrslv->params.key_len = key_len; + nrslv->params.max_size = max_size; + nrslv->params.min_size =256 ; + nrslv->params.automatic_shrinking = true; + nrslv->params.obj_cmpfn = cmp_fn ? net_rslv_cmp :NULL ;
This completely defeats the rhashtable inlining since that relies on the parameter being constant.
Looking at your next patch you have exactly one user for this. So who is going to be the next user and do we really need all these fields to be variable?
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Thomas Graf
maintainerRe: [PATCH net-next 5/7] rhashtable: abstract out function to get hash
In reply to Herbert XuQuoted 10 lines · Herbert Xu
Quoted 6 lines · Tom Herbert
Split out most of
rht_key_hashfnwhich is calculating the hash into its own function. This way the hash function can be called separately to get the hash value.Acked-by Thomas Graf <[email protected]>Signed-off-by Tom Herbert <[email protected]>I don't get this one. You're just using jhash, right? Why not call jhash directly instead of
rht_get_key_hashfn?
FYI, there is a v2 of this series, just so you don't have to do the work twice.
I understand this particular patch as an effort not to duplicate hash function selection such as jhash vs jhash2 based on key_len.
Herbert Xu
maintainerRe: [PATCH net-next 5/7] rhashtable: abstract out function to get hash
Quoted 3 lines · Thomas Graf
I understand this particular patch as an effort not to duplicate hash function selection such as jhash vs jhash2 based on
key_len.
If the rhashtable params stay non-const as is then this is going to produce some monstrous code which will be worse than using jhash unconditionally.
If the rhashtable params are made const then you'll already know whether jhash or jhash2 is used.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH net-next 5/7] rhashtable: abstract out function to get hash
Quoted 9 lines · Herbert Xu
Quoted 3 lines · Thomas Graf
I understand this particular patch as an effort not to duplicate hash function selection such as jhash vs jhash2 based on
key_len.If the rhashtable params stay non-const as is then this is going to produce some monstrous code which will be worse than using jhash unconditionally.
I will look at keep params constant.
Tom
Quoted 8 lines
If the rhashtable params are made const then you'll already know whether jhash or jhash2 is used.
Cheers,
--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt