Skip to content

Commit baf3b3f

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next
Steffen Klassert says: ==================== 1) Some constifications, from Mathias Krause. 2) Catch bugs if a hold timer is still active when xfrm_policy_destroy() is called, from Fan Du. 3) Remove a redundant address family checking, from Fan Du. 4) Make xfrm_state timer monotonic to be independent of system clock changes, from Fan Du. 5) Remove an outdated comment on returning -EREMOTE in the xfrm_lookup(), from Rami Rosen. Please pull or let me know if there are problems. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 3bca8de + e3fec5a commit baf3b3f

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8, int dir, u32
15481548
int xfrm_policy_flush(struct net *net, u8 type, struct xfrm_audit *audit_info);
15491549
u32 xfrm_get_acqseq(void);
15501550
extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
1551-
struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark,
1551+
struct xfrm_state *xfrm_find_acq(struct net *net, const struct xfrm_mark *mark,
15521552
u8 mode, u32 reqid, u8 proto,
15531553
const xfrm_address_t *daddr,
15541554
const xfrm_address_t *saddr, int create,

net/key/af_key.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct netns_pfkey {
4545
static DEFINE_MUTEX(pfkey_mutex);
4646

4747
#define DUMMY_MARK 0
48-
static struct xfrm_mark dummy_mark = {0, 0};
48+
static const struct xfrm_mark dummy_mark = {0, 0};
4949
struct pfkey_sock {
5050
/* struct sock must be the first member of struct pfkey_sock */
5151
struct sock sk;
@@ -338,7 +338,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk)
338338
return 0;
339339
}
340340

341-
static u8 sadb_ext_min_len[] = {
341+
static const u8 sadb_ext_min_len[] = {
342342
[SADB_EXT_RESERVED] = (u8) 0,
343343
[SADB_EXT_SA] = (u8) sizeof(struct sadb_sa),
344344
[SADB_EXT_LIFETIME_CURRENT] = (u8) sizeof(struct sadb_lifetime),
@@ -1196,10 +1196,6 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
11961196

11971197
x->props.family = pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_SRC-1],
11981198
&x->props.saddr);
1199-
if (!x->props.family) {
1200-
err = -EAFNOSUPPORT;
1201-
goto out;
1202-
}
12031199
pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_DST-1],
12041200
&x->id.daddr);
12051201

@@ -2205,10 +2201,6 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, const struct sadb_
22052201

22062202
sa = ext_hdrs[SADB_EXT_ADDRESS_SRC-1];
22072203
xp->family = pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.saddr);
2208-
if (!xp->family) {
2209-
err = -EINVAL;
2210-
goto out;
2211-
}
22122204
xp->selector.family = xp->family;
22132205
xp->selector.prefixlen_s = sa->sadb_address_prefixlen;
22142206
xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
@@ -2737,7 +2729,7 @@ static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, const struct sad
27372729

27382730
typedef int (*pfkey_handler)(struct sock *sk, struct sk_buff *skb,
27392731
const struct sadb_msg *hdr, void * const *ext_hdrs);
2740-
static pfkey_handler pfkey_funcs[SADB_MAX + 1] = {
2732+
static const pfkey_handler pfkey_funcs[SADB_MAX + 1] = {
27412733
[SADB_RESERVED] = pfkey_reserved,
27422734
[SADB_GETSPI] = pfkey_getspi,
27432735
[SADB_UPDATE] = pfkey_add,

net/xfrm/xfrm_policy.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
308308
{
309309
BUG_ON(!policy->walk.dead);
310310

311-
if (del_timer(&policy->timer))
311+
if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
312312
BUG();
313313

314314
security_xfrm_policy_free(policy->security);
@@ -2132,8 +2132,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
21322132
* have the xfrm_state's. We need to wait for KM to
21332133
* negotiate new SA's or bail out with error.*/
21342134
if (net->xfrm.sysctl_larval_drop) {
2135-
/* EREMOTE tells the caller to generate
2136-
* a one-shot blackhole route. */
21372135
dst_release(dst);
21382136
xfrm_pols_put(pols, drop_pols);
21392137
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES);

net/xfrm/xfrm_state.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ struct xfrm_state *xfrm_state_alloc(struct net *net)
499499
INIT_HLIST_NODE(&x->bydst);
500500
INIT_HLIST_NODE(&x->bysrc);
501501
INIT_HLIST_NODE(&x->byspi);
502-
tasklet_hrtimer_init(&x->mtimer, xfrm_timer_handler, CLOCK_REALTIME, HRTIMER_MODE_ABS);
502+
tasklet_hrtimer_init(&x->mtimer, xfrm_timer_handler,
503+
CLOCK_BOOTTIME, HRTIMER_MODE_ABS);
503504
setup_timer(&x->rtimer, xfrm_replay_timer_handler,
504505
(unsigned long)x);
505506
x->curlft.add_time = get_seconds();
@@ -990,11 +991,13 @@ void xfrm_state_insert(struct xfrm_state *x)
990991
EXPORT_SYMBOL(xfrm_state_insert);
991992

992993
/* xfrm_state_lock is held */
993-
static struct xfrm_state *__find_acq_core(struct net *net, struct xfrm_mark *m,
994+
static struct xfrm_state *__find_acq_core(struct net *net,
995+
const struct xfrm_mark *m,
994996
unsigned short family, u8 mode,
995997
u32 reqid, u8 proto,
996998
const xfrm_address_t *daddr,
997-
const xfrm_address_t *saddr, int create)
999+
const xfrm_address_t *saddr,
1000+
int create)
9981001
{
9991002
unsigned int h = xfrm_dst_hash(net, daddr, saddr, reqid, family);
10001003
struct xfrm_state *x;
@@ -1399,9 +1402,9 @@ xfrm_state_lookup_byaddr(struct net *net, u32 mark,
13991402
EXPORT_SYMBOL(xfrm_state_lookup_byaddr);
14001403

14011404
struct xfrm_state *
1402-
xfrm_find_acq(struct net *net, struct xfrm_mark *mark, u8 mode, u32 reqid, u8 proto,
1403-
const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1404-
int create, unsigned short family)
1405+
xfrm_find_acq(struct net *net, const struct xfrm_mark *mark, u8 mode, u32 reqid,
1406+
u8 proto, const xfrm_address_t *daddr,
1407+
const xfrm_address_t *saddr, int create, unsigned short family)
14051408
{
14061409
struct xfrm_state *x;
14071410

0 commit comments

Comments
 (0)