Message ID | 20210907193510.16487-3-nicolas.dichtel@6wind.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | xfrm: fix uapi for the default policy | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
Hi Nicolas, Thank you for the patch! Yet something to improve: [auto build test ERROR on ipsec-next/master] [also build test ERROR on net-next/master net/master next-20210907] [cannot apply to ipsec/master v5.14] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Nicolas-Dichtel/xfrm-make-user-policy-API-complete/20210908-043604 base: https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master config: x86_64-randconfig-a011-20210906 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 9c476172b93367d2cb88d7d3f4b1b5b456fa6020) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/6f3af39482e7fa1c873b3e6ee460a03feb7b796a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Nicolas-Dichtel/xfrm-make-user-policy-API-complete/20210908-043604 git checkout 6f3af39482e7fa1c873b3e6ee460a03feb7b796a # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> net/xfrm/xfrm_user.c:1991:30: error: passing 'const struct net *' to parameter of type 'struct net *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY); ^~~ net/xfrm/xfrm_user.c:1154:52: note: passing argument to parameter 'net' here static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb, ^ net/xfrm/xfrm_user.c:2027:41: warning: variable 'up' set but not used [-Wunused-but-set-variable] struct xfrm_userpolicy_default *r_up, *up; ^ 1 warning and 1 error generated. vim +1991 net/xfrm/xfrm_user.c 1963 1964 static int xfrm_notify_userpolicy(const struct net *net) 1965 { 1966 struct xfrm_userpolicy_default *up; 1967 int len = NLMSG_ALIGN(sizeof(*up)); 1968 struct nlmsghdr *nlh; 1969 struct sk_buff *skb; 1970 1971 skb = nlmsg_new(len, GFP_ATOMIC); 1972 if (skb == NULL) 1973 return -ENOMEM; 1974 1975 nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_GETDEFAULT, sizeof(*up), 0); 1976 if (nlh == NULL) { 1977 kfree_skb(skb); 1978 return -EMSGSIZE; 1979 } 1980 1981 up = nlmsg_data(nlh); 1982 up->in = net->xfrm.policy_default & XFRM_POL_DEFAULT_IN ? 1983 XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT; 1984 up->fwd = net->xfrm.policy_default & XFRM_POL_DEFAULT_FWD ? 1985 XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT; 1986 up->out = net->xfrm.policy_default & XFRM_POL_DEFAULT_OUT ? 1987 XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT; 1988 1989 nlmsg_end(skb, nlh); 1990 > 1991 return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY); 1992 } 1993 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 4e1c4dd53fe2..af9803f18ff7 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -1961,6 +1961,36 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb, return skb; } +static int xfrm_notify_userpolicy(const struct net *net) +{ + struct xfrm_userpolicy_default *up; + int len = NLMSG_ALIGN(sizeof(*up)); + struct nlmsghdr *nlh; + struct sk_buff *skb; + + skb = nlmsg_new(len, GFP_ATOMIC); + if (skb == NULL) + return -ENOMEM; + + nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_GETDEFAULT, sizeof(*up), 0); + if (nlh == NULL) { + kfree_skb(skb); + return -EMSGSIZE; + } + + up = nlmsg_data(nlh); + up->in = net->xfrm.policy_default & XFRM_POL_DEFAULT_IN ? + XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT; + up->fwd = net->xfrm.policy_default & XFRM_POL_DEFAULT_FWD ? + XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT; + up->out = net->xfrm.policy_default & XFRM_POL_DEFAULT_OUT ? + XFRM_USERPOLICY_BLOCK : XFRM_USERPOLICY_ACCEPT; + + nlmsg_end(skb, nlh); + + return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY); +} + static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh, struct nlattr **attrs) { @@ -1984,6 +2014,7 @@ static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh, rt_genid_bump_all(net); + xfrm_notify_userpolicy(net); return 0; }
This configuration knob is very sensible, it should be notified when changing. Fixes: 2d151d39073a ("xfrm: Add possibility to set the default to block if we have no policy") Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> --- net/xfrm/xfrm_user.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)