Skip to content

Commit 88d0adb

Browse files
NicolasDichtelklassert
authored andcommitted
xfrm: notify default policy on update
This configuration knob is very sensible, it should be notified when changing. Fixes: 2d151d3 ("xfrm: Add possibility to set the default to block if we have no policy") Signed-off-by: Nicolas Dichtel <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent f8d858e commit 88d0adb

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

net/xfrm/xfrm_user.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,36 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
19611961
return skb;
19621962
}
19631963

1964+
static int xfrm_notify_userpolicy(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+
19641994
static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,
19651995
struct nlattr **attrs)
19661996
{
@@ -1984,6 +2014,7 @@ static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,
19842014

19852015
rt_genid_bump_all(net);
19862016

2017+
xfrm_notify_userpolicy(net);
19872018
return 0;
19882019
}
19892020

0 commit comments

Comments
 (0)