diff mbox

[2/2] xfrm: add UDP encapsulation port in migrate message

Message ID 20170605215625.11043-3-antony@phenome.org
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Antony Antony June 5, 2017, 9:56 p.m. UTC
Add XFRMA_ENCAP, UDP encapsulation port, to km_migrate announcement
to userland. Only add if XFRMA_ENCAP was in user migrate request.

Signed-off-by: Antony Antony <antony@phenome.org>
---
 include/net/xfrm.h     |  5 +++--
 net/key/af_key.c       |  3 ++-
 net/xfrm/xfrm_policy.c |  2 +-
 net/xfrm/xfrm_state.c  |  5 +++--
 net/xfrm/xfrm_user.c   | 23 +++++++++++++++++------
 5 files changed, 26 insertions(+), 12 deletions(-)

Comments

Richard Guy Briggs June 6, 2017, 12:05 a.m. UTC | #1
On 2017-06-05 23:56, Antony Antony wrote:
> Add XFRMA_ENCAP, UDP encapsulation port, to km_migrate announcement
> to userland. Only add if XFRMA_ENCAP was in user migrate request.
> 
> Signed-off-by: Antony Antony <antony@phenome.org>

Looks reasonable to me.
Reviewed-by: Richard Guy Briggs <rgb@tricolour.ca>

> ---
>  include/net/xfrm.h     |  5 +++--
>  net/key/af_key.c       |  3 ++-
>  net/xfrm/xfrm_policy.c |  2 +-
>  net/xfrm/xfrm_state.c  |  5 +++--
>  net/xfrm/xfrm_user.c   | 23 +++++++++++++++++------
>  5 files changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> index df98463..9fb75fb 100644
> --- a/include/net/xfrm.h
> +++ b/include/net/xfrm.h
> @@ -631,7 +631,8 @@ struct xfrm_mgr {
>  					   u8 dir, u8 type,
>  					   const struct xfrm_migrate *m,
>  					   int num_bundles,
> -					   const struct xfrm_kmaddress *k);
> +					   const struct xfrm_kmaddress *k,
> +					   struct xfrm_encap_tmpl *encap);
>  	bool			(*is_alive)(const struct km_event *c);
>  };
>  
> @@ -1675,7 +1676,7 @@ int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
>  #ifdef CONFIG_XFRM_MIGRATE
>  int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  	       const struct xfrm_migrate *m, int num_bundles,
> -	       const struct xfrm_kmaddress *k);
> +	       const struct xfrm_kmaddress *k, struct xfrm_encap_tmpl *encap);
>  struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net);
>  struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
>  				      struct xfrm_migrate *m,
> diff --git a/net/key/af_key.c b/net/key/af_key.c
> index 56df9fb..2ad2286 100644
> --- a/net/key/af_key.c
> +++ b/net/key/af_key.c
> @@ -3508,7 +3508,8 @@ static int set_ipsecrequest(struct sk_buff *skb,
>  #ifdef CONFIG_NET_KEY_MIGRATE
>  static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  			      const struct xfrm_migrate *m, int num_bundles,
> -			      const struct xfrm_kmaddress *k)
> +			      const struct xfrm_kmaddress *k,
> +			      struct xfrm_encap_tmpl *encap)
>  {
>  	int i;
>  	int sasize_sel;
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index eaecfa4..7152147 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -3337,7 +3337,7 @@ int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  	}
>  
>  	/* Stage 5 - announce */
> -	km_migrate(sel, dir, type, m, num_migrate, k);
> +	km_migrate(sel, dir, type, m, num_migrate, k, encap);
>  
>  	xfrm_pol_put(pol);
>  
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index ae6206b..d6220f7 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1966,7 +1966,7 @@ EXPORT_SYMBOL(km_policy_expired);
>  #ifdef CONFIG_XFRM_MIGRATE
>  int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  	       const struct xfrm_migrate *m, int num_migrate,
> -	       const struct xfrm_kmaddress *k)
> +	       const struct xfrm_kmaddress *k, struct xfrm_encap_tmpl *encap)
>  {
>  	int err = -EINVAL;
>  	int ret;
> @@ -1975,7 +1975,8 @@ int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  	rcu_read_lock();
>  	list_for_each_entry_rcu(km, &xfrm_km_list, list) {
>  		if (km->migrate) {
> -			ret = km->migrate(sel, dir, type, m, num_migrate, k);
> +			ret = km->migrate(sel, dir, type, m, num_migrate, k,
> +					  encap);
>  			if (!ret)
>  				err = ret;
>  		}
> diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> index fb98892..8c54484 100644
> --- a/net/xfrm/xfrm_user.c
> +++ b/net/xfrm/xfrm_user.c
> @@ -2314,17 +2314,20 @@ static int copy_to_user_kmaddress(const struct xfrm_kmaddress *k, struct sk_buff
>  	return nla_put(skb, XFRMA_KMADDRESS, sizeof(uk), &uk);
>  }
>  
> -static inline size_t xfrm_migrate_msgsize(int num_migrate, int with_kma)
> +static inline size_t xfrm_migrate_msgsize(int num_migrate, int with_kma,
> +					  int with_encp)
>  {
>  	return NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_id))
>  	      + (with_kma ? nla_total_size(sizeof(struct xfrm_kmaddress)) : 0)
> +	      + (with_encp ? nla_total_size(sizeof(struct xfrm_encap_tmpl)) : 0)
>  	      + nla_total_size(sizeof(struct xfrm_user_migrate) * num_migrate)
>  	      + userpolicy_type_attrsize();
>  }
>  
>  static int build_migrate(struct sk_buff *skb, const struct xfrm_migrate *m,
>  			 int num_migrate, const struct xfrm_kmaddress *k,
> -			 const struct xfrm_selector *sel, u8 dir, u8 type)
> +			 const struct xfrm_selector *sel,
> +			 struct xfrm_encap_tmpl *encap, u8 dir, u8 type)
>  {
>  	const struct xfrm_migrate *mp;
>  	struct xfrm_userpolicy_id *pol_id;
> @@ -2346,6 +2349,11 @@ static int build_migrate(struct sk_buff *skb, const struct xfrm_migrate *m,
>  		if (err)
>  			goto out_cancel;
>  	}
> +	if (encap) {
> +		err = nla_put(skb, XFRMA_ENCAP, sizeof(*encap), encap);
> +		if (err)
> +			goto out_cancel;
> +	}
>  	err = copy_to_user_policy_type(type, skb);
>  	if (err)
>  		goto out_cancel;
> @@ -2365,17 +2373,19 @@ static int build_migrate(struct sk_buff *skb, const struct xfrm_migrate *m,
>  
>  static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  			     const struct xfrm_migrate *m, int num_migrate,
> -			     const struct xfrm_kmaddress *k)
> +			     const struct xfrm_kmaddress *k,
> +			     struct xfrm_encap_tmpl *encap)
>  {
>  	struct net *net = &init_net;
>  	struct sk_buff *skb;
>  
> -	skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k), GFP_ATOMIC);
> +	skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k, !!encap),
> +			GFP_ATOMIC);
>  	if (skb == NULL)
>  		return -ENOMEM;
>  
>  	/* build migrate */
> -	if (build_migrate(skb, m, num_migrate, k, sel, dir, type) < 0)
> +	if (build_migrate(skb, m, num_migrate, k, sel, encap, dir, type) < 0)
>  		BUG();
>  
>  	return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MIGRATE);
> @@ -2383,7 +2393,8 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  #else
>  static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
>  			     const struct xfrm_migrate *m, int num_migrate,
> -			     const struct xfrm_kmaddress *k)
> +			     const struct xfrm_kmaddress *k,
> +			     struct xfrm_encap_tmpl *encap)
>  {
>  	return -ENOPROTOOPT;
>  }
> -- 
> 2.9.3

	slainte mhath, RGB

--
Richard Guy Briggs               --  ~\    -- ~\             <hpv.tricolour.ca>
<www.TriColour.ca>                 --  \___   o \@      @        Ride yer bike!
Ottawa, ON, CANADA                  --  Lo_>__M__\\/\%__\\/\%
Vote! -- <greenparty.ca>_____GTVS6#790__(*)__(*)________(*)(*)_________________
kernel test robot June 6, 2017, 4:53 a.m. UTC | #2
Hi Antony,

[auto build test ERROR on ipsec-next/master]
[also build test ERROR on v4.12-rc4 next-20170605]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Antony-Antony/add-udp-encapsulation-port-to-xfrm_do_migrate/20170606-114911
base:   https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master
config: x86_64-randconfig-x015-201723 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> net//key/af_key.c:3836:13: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .migrate = pfkey_send_migrate,
                ^~~~~~~~~~~~~~~~~~
   net//key/af_key.c:3836:13: note: (near initialization for 'pfkeyv2_mgr.migrate')
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:__set_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
   Cyclomatic Complexity 1 include/linux/list.h:hlist_unhashed
   Cyclomatic Complexity 1 include/linux/list.h:hlist_empty
   Cyclomatic Complexity 2 include/linux/list.h:__hlist_del
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 1 include/linux/err.h:ERR_PTR
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_read
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_set
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_add
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_inc
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_dec
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_dec_and_test
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_add_return
   Cyclomatic Complexity 5 arch/x86/include/asm/preempt.h:__preempt_count_add
   Cyclomatic Complexity 5 arch/x86/include/asm/preempt.h:__preempt_count_sub
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock_bh
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_bh
   Cyclomatic Complexity 1 include/linux/rcupdate.h:__rcu_read_lock
   Cyclomatic Complexity 1 include/linux/rcupdate.h:__rcu_read_unlock
   Cyclomatic Complexity 1 include/linux/rcupdate.h:synchronize_rcu
   Cyclomatic Complexity 1 include/linux/rcutiny.h:rcu_is_watching
   Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_lock_acquire
   Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_lock_release
   Cyclomatic Complexity 4 include/linux/rcupdate.h:rcu_read_lock
   Cyclomatic Complexity 4 include/linux/rcupdate.h:rcu_read_unlock
   Cyclomatic Complexity 3 include/linux/rculist.h:hlist_add_head_rcu
   Cyclomatic Complexity 1 include/linux/kasan.h:kasan_kmalloc
   Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
   Cyclomatic Complexity 1 include/linux/slab.h:kmem_cache_alloc_trace
   Cyclomatic Complexity 1 include/linux/slab.h:kmalloc_order_trace
   Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/skbuff.h:alloc_skb
   Cyclomatic Complexity 1 include/linux/skbuff.h:skb_end_pointer
   Cyclomatic Complexity 3 include/linux/skbuff.h:skb_cloned
   Cyclomatic Complexity 1 include/linux/skbuff.h:skb_reset_transport_header
   Cyclomatic Complexity 2 include/linux/skbuff.h:skb_orphan
   Cyclomatic Complexity 1 include/linux/skbuff.h:skb_copy_datagram_msg
   Cyclomatic Complexity 2 include/linux/skbuff.h:memcpy_from_msg
   Cyclomatic Complexity 1 include/linux/seq_file.h:seq_user_ns
   Cyclomatic Complexity 1 include/linux/seq_file_net.h:seq_file_net
   Cyclomatic Complexity 1 include/net/net_namespace.h:read_pnet
   Cyclomatic Complexity 1 include/linux/proc_fs.h:proc_create
   Cyclomatic Complexity 4 include/net/netns/generic.h:net_generic
   Cyclomatic Complexity 1 include/net/sock.h:sk_entry
   Cyclomatic Complexity 1 include/net/sock.h:sk_unhashed
   Cyclomatic Complexity 1 include/net/sock.h:sk_hashed
   Cyclomatic Complexity 1 include/net/sock.h:sk_node_init
   Cyclomatic Complexity 1 include/net/sock.h:__sk_del_node
   Cyclomatic Complexity 2 include/net/sock.h:__sk_del_node_init
   Cyclomatic Complexity 1 include/net/sock.h:sock_hold
   Cyclomatic Complexity 1 include/net/sock.h:__sock_put
   Cyclomatic Complexity 3 include/net/sock.h:sk_del_node_init
   Cyclomatic Complexity 1 include/net/sock.h:sk_add_node_rcu
   Cyclomatic Complexity 1 include/net/sock.h:sock_set_flag
   Cyclomatic Complexity 2 include/net/sock.h:sock_flag
   Cyclomatic Complexity 1 include/net/sock.h:sk_has_account
   Cyclomatic Complexity 2 include/net/sock.h:sk_mem_charge
   Cyclomatic Complexity 2 include/net/sock.h:sock_put
   Cyclomatic Complexity 1 include/net/sock.h:sk_tx_queue_clear
   Cyclomatic Complexity 1 include/net/sock.h:sk_set_socket
   Cyclomatic Complexity 1 include/net/sock.h:sock_orphan
   Cyclomatic Complexity 1 include/net/sock.h:sk_wmem_alloc_get
   Cyclomatic Complexity 1 include/net/sock.h:sk_rmem_alloc_get
   Cyclomatic Complexity 1 include/net/sock.h:skb_set_owner_r
   Cyclomatic Complexity 5 include/net/sock.h:sock_recv_ts_and_drops
   Cyclomatic Complexity 1 include/net/sock.h:sock_net
   Cyclomatic Complexity 1 include/net/ipv6.h:ipv6_addr_equal
   Cyclomatic Complexity 1 include/net/xfrm.h:xs_net
   Cyclomatic Complexity 1 include/net/xfrm.h:xp_net
   Cyclomatic Complexity 2 include/net/xfrm.h:xfrm_pol_put
   Cyclomatic Complexity 1 include/net/xfrm.h:__xfrm_state_put
   Cyclomatic Complexity 2 include/net/xfrm.h:xfrm_state_put
   Cyclomatic Complexity 1 include/net/xfrm.h:xfrm_state_hold
   Cyclomatic Complexity 1 include/net/xfrm.h:xfrm_state_kern
   Cyclomatic Complexity 1 include/net/xfrm.h:xfrm6_addr_equal
   Cyclomatic Complexity 2 include/net/xfrm.h:xfrm_addr_equal
   Cyclomatic Complexity 1 include/net/xfrm.h:xfrm_policy_id2dir
   Cyclomatic Complexity 1 net//key/af_key.c:pfkey_sk
   Cyclomatic Complexity 2 net//key/af_key.c:pfkey_can_dump
   Cyclomatic Complexity 1 net//key/af_key.c:pfkey_hdr_dup
   Cyclomatic Complexity 4 net//key/af_key.c:verify_address_len
   Cyclomatic Complexity 1 net//key/af_key.c:pfkey_sec_ctx_len
   Cyclomatic Complexity 3 net//key/af_key.c:verify_sec_ctx_len
   Cyclomatic Complexity 2 net//key/af_key.c:pfkey_sadb2xfrm_user_sec_ctx
   Cyclomatic Complexity 4 net//key/af_key.c:present_and_same_family
   Cyclomatic Complexity 11 net//key/af_key.c:parse_exthdrs
   Cyclomatic Complexity 5 net//key/af_key.c:pfkey_satype2proto
   Cyclomatic Complexity 4 net//key/af_key.c:pfkey_proto2satype

vim +3836 net//key/af_key.c

61145aa1 Pavel Emelyanov   2008-02-09  3820  {
61145aa1 Pavel Emelyanov   2008-02-09  3821  	return 0;
61145aa1 Pavel Emelyanov   2008-02-09  3822  }
61145aa1 Pavel Emelyanov   2008-02-09  3823  
2c8c1e72 Alexey Dobriyan   2010-01-17  3824  static inline void pfkey_exit_proc(struct net *net)
61145aa1 Pavel Emelyanov   2008-02-09  3825  {
61145aa1 Pavel Emelyanov   2008-02-09  3826  }
^1da177e Linus Torvalds    2005-04-16  3827  #endif
^1da177e Linus Torvalds    2005-04-16  3828  
^1da177e Linus Torvalds    2005-04-16  3829  static struct xfrm_mgr pfkeyv2_mgr =
^1da177e Linus Torvalds    2005-04-16  3830  {
^1da177e Linus Torvalds    2005-04-16  3831  	.notify		= pfkey_send_notify,
^1da177e Linus Torvalds    2005-04-16  3832  	.acquire	= pfkey_send_acquire,
^1da177e Linus Torvalds    2005-04-16  3833  	.compile_policy	= pfkey_compile_policy,
^1da177e Linus Torvalds    2005-04-16  3834  	.new_mapping	= pfkey_send_new_mapping,
26b15dad Jamal Hadi Salim  2005-06-18  3835  	.notify_policy	= pfkey_send_policy_notify,
08de61be Shinta Sugimoto   2007-02-08 @3836  	.migrate	= pfkey_send_migrate,
0f24558e Horia Geanta      2014-02-12  3837  	.is_alive	= pfkey_is_alive,
^1da177e Linus Torvalds    2005-04-16  3838  };
^1da177e Linus Torvalds    2005-04-16  3839  
3fa87a32 Alexey Dobriyan   2008-11-25  3840  static int __net_init pfkey_net_init(struct net *net)
3fa87a32 Alexey Dobriyan   2008-11-25  3841  {
23c049ca Eric W. Biederman 2009-11-29  3842  	struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
3fa87a32 Alexey Dobriyan   2008-11-25  3843  	int rv;
3fa87a32 Alexey Dobriyan   2008-11-25  3844  

:::::: The code at line 3836 was first introduced by commit
:::::: 08de61beab8a21c8e0b3906a97defda5f1f66ece [PFKEYV2]: Extension for dynamic update of endpoint address(es)

:::::: TO: Shinta Sugimoto <shinta.sugimoto@ericsson.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 6, 2017, 6:04 a.m. UTC | #3
Hi Antony,

[auto build test WARNING on ipsec-next/master]
[also build test WARNING on v4.12-rc4 next-20170605]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Antony-Antony/add-udp-encapsulation-port-to-xfrm_do_migrate/20170606-114911
base:   https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master
config: m68k-sun3_defconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All warnings (new ones prefixed by >>):

>> net/key/af_key.c:3836:2: warning: initialization from incompatible pointer type
     .migrate = pfkey_send_migrate,
     ^
   net/key/af_key.c:3836:2: warning: (near initialization for 'pfkeyv2_mgr.migrate')

vim +3836 net/key/af_key.c

61145aa1 Pavel Emelyanov   2008-02-09  3820  {
61145aa1 Pavel Emelyanov   2008-02-09  3821  	return 0;
61145aa1 Pavel Emelyanov   2008-02-09  3822  }
61145aa1 Pavel Emelyanov   2008-02-09  3823  
2c8c1e72 Alexey Dobriyan   2010-01-17  3824  static inline void pfkey_exit_proc(struct net *net)
61145aa1 Pavel Emelyanov   2008-02-09  3825  {
61145aa1 Pavel Emelyanov   2008-02-09  3826  }
^1da177e Linus Torvalds    2005-04-16  3827  #endif
^1da177e Linus Torvalds    2005-04-16  3828  
^1da177e Linus Torvalds    2005-04-16  3829  static struct xfrm_mgr pfkeyv2_mgr =
^1da177e Linus Torvalds    2005-04-16  3830  {
^1da177e Linus Torvalds    2005-04-16  3831  	.notify		= pfkey_send_notify,
^1da177e Linus Torvalds    2005-04-16  3832  	.acquire	= pfkey_send_acquire,
^1da177e Linus Torvalds    2005-04-16  3833  	.compile_policy	= pfkey_compile_policy,
^1da177e Linus Torvalds    2005-04-16  3834  	.new_mapping	= pfkey_send_new_mapping,
26b15dad Jamal Hadi Salim  2005-06-18  3835  	.notify_policy	= pfkey_send_policy_notify,
08de61be Shinta Sugimoto   2007-02-08 @3836  	.migrate	= pfkey_send_migrate,
0f24558e Horia Geanta      2014-02-12  3837  	.is_alive	= pfkey_is_alive,
^1da177e Linus Torvalds    2005-04-16  3838  };
^1da177e Linus Torvalds    2005-04-16  3839  
3fa87a32 Alexey Dobriyan   2008-11-25  3840  static int __net_init pfkey_net_init(struct net *net)
3fa87a32 Alexey Dobriyan   2008-11-25  3841  {
23c049ca Eric W. Biederman 2009-11-29  3842  	struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
3fa87a32 Alexey Dobriyan   2008-11-25  3843  	int rv;
3fa87a32 Alexey Dobriyan   2008-11-25  3844  

:::::: The code at line 3836 was first introduced by commit
:::::: 08de61beab8a21c8e0b3906a97defda5f1f66ece [PFKEYV2]: Extension for dynamic update of endpoint address(es)

:::::: TO: Shinta Sugimoto <shinta.sugimoto@ericsson.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index df98463..9fb75fb 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -631,7 +631,8 @@  struct xfrm_mgr {
 					   u8 dir, u8 type,
 					   const struct xfrm_migrate *m,
 					   int num_bundles,
-					   const struct xfrm_kmaddress *k);
+					   const struct xfrm_kmaddress *k,
+					   struct xfrm_encap_tmpl *encap);
 	bool			(*is_alive)(const struct km_event *c);
 };
 
@@ -1675,7 +1676,7 @@  int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
 #ifdef CONFIG_XFRM_MIGRATE
 int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 	       const struct xfrm_migrate *m, int num_bundles,
-	       const struct xfrm_kmaddress *k);
+	       const struct xfrm_kmaddress *k, struct xfrm_encap_tmpl *encap);
 struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net);
 struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,
 				      struct xfrm_migrate *m,
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 56df9fb..2ad2286 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3508,7 +3508,8 @@  static int set_ipsecrequest(struct sk_buff *skb,
 #ifdef CONFIG_NET_KEY_MIGRATE
 static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 			      const struct xfrm_migrate *m, int num_bundles,
-			      const struct xfrm_kmaddress *k)
+			      const struct xfrm_kmaddress *k,
+			      struct xfrm_encap_tmpl *encap)
 {
 	int i;
 	int sasize_sel;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index eaecfa4..7152147 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3337,7 +3337,7 @@  int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 	}
 
 	/* Stage 5 - announce */
-	km_migrate(sel, dir, type, m, num_migrate, k);
+	km_migrate(sel, dir, type, m, num_migrate, k, encap);
 
 	xfrm_pol_put(pol);
 
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index ae6206b..d6220f7 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1966,7 +1966,7 @@  EXPORT_SYMBOL(km_policy_expired);
 #ifdef CONFIG_XFRM_MIGRATE
 int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 	       const struct xfrm_migrate *m, int num_migrate,
-	       const struct xfrm_kmaddress *k)
+	       const struct xfrm_kmaddress *k, struct xfrm_encap_tmpl *encap)
 {
 	int err = -EINVAL;
 	int ret;
@@ -1975,7 +1975,8 @@  int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 	rcu_read_lock();
 	list_for_each_entry_rcu(km, &xfrm_km_list, list) {
 		if (km->migrate) {
-			ret = km->migrate(sel, dir, type, m, num_migrate, k);
+			ret = km->migrate(sel, dir, type, m, num_migrate, k,
+					  encap);
 			if (!ret)
 				err = ret;
 		}
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index fb98892..8c54484 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2314,17 +2314,20 @@  static int copy_to_user_kmaddress(const struct xfrm_kmaddress *k, struct sk_buff
 	return nla_put(skb, XFRMA_KMADDRESS, sizeof(uk), &uk);
 }
 
-static inline size_t xfrm_migrate_msgsize(int num_migrate, int with_kma)
+static inline size_t xfrm_migrate_msgsize(int num_migrate, int with_kma,
+					  int with_encp)
 {
 	return NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_id))
 	      + (with_kma ? nla_total_size(sizeof(struct xfrm_kmaddress)) : 0)
+	      + (with_encp ? nla_total_size(sizeof(struct xfrm_encap_tmpl)) : 0)
 	      + nla_total_size(sizeof(struct xfrm_user_migrate) * num_migrate)
 	      + userpolicy_type_attrsize();
 }
 
 static int build_migrate(struct sk_buff *skb, const struct xfrm_migrate *m,
 			 int num_migrate, const struct xfrm_kmaddress *k,
-			 const struct xfrm_selector *sel, u8 dir, u8 type)
+			 const struct xfrm_selector *sel,
+			 struct xfrm_encap_tmpl *encap, u8 dir, u8 type)
 {
 	const struct xfrm_migrate *mp;
 	struct xfrm_userpolicy_id *pol_id;
@@ -2346,6 +2349,11 @@  static int build_migrate(struct sk_buff *skb, const struct xfrm_migrate *m,
 		if (err)
 			goto out_cancel;
 	}
+	if (encap) {
+		err = nla_put(skb, XFRMA_ENCAP, sizeof(*encap), encap);
+		if (err)
+			goto out_cancel;
+	}
 	err = copy_to_user_policy_type(type, skb);
 	if (err)
 		goto out_cancel;
@@ -2365,17 +2373,19 @@  static int build_migrate(struct sk_buff *skb, const struct xfrm_migrate *m,
 
 static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 			     const struct xfrm_migrate *m, int num_migrate,
-			     const struct xfrm_kmaddress *k)
+			     const struct xfrm_kmaddress *k,
+			     struct xfrm_encap_tmpl *encap)
 {
 	struct net *net = &init_net;
 	struct sk_buff *skb;
 
-	skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k), GFP_ATOMIC);
+	skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k, !!encap),
+			GFP_ATOMIC);
 	if (skb == NULL)
 		return -ENOMEM;
 
 	/* build migrate */
-	if (build_migrate(skb, m, num_migrate, k, sel, dir, type) < 0)
+	if (build_migrate(skb, m, num_migrate, k, sel, encap, dir, type) < 0)
 		BUG();
 
 	return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MIGRATE);
@@ -2383,7 +2393,8 @@  static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 #else
 static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 			     const struct xfrm_migrate *m, int num_migrate,
-			     const struct xfrm_kmaddress *k)
+			     const struct xfrm_kmaddress *k,
+			     struct xfrm_encap_tmpl *encap)
 {
 	return -ENOPROTOOPT;
 }