Commit 26a8ba2c authored by David S. Miller's avatar David S. Miller

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next

Steffen Klassert says:

====================
pull request (net-next): ipsec-next 2017-10-30

1) Change some variables that can't be negative
   from int to unsigned int. From Alexey Dobriyan.

2) Remove a redundant header initialization in esp6.
   From Colin Ian King.

3) Some BUG to BUG_ON conversions.
   From Gustavo A. R. Silva.

Please pull or let me know if there are problems.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 28ef7de7 eee12df5
...@@ -1764,22 +1764,22 @@ static inline int xfrm_acquire_is_on(struct net *net) ...@@ -1764,22 +1764,22 @@ static inline int xfrm_acquire_is_on(struct net *net)
} }
#endif #endif
static inline int aead_len(struct xfrm_algo_aead *alg) static inline unsigned int aead_len(struct xfrm_algo_aead *alg)
{ {
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
} }
static inline int xfrm_alg_len(const struct xfrm_algo *alg) static inline unsigned int xfrm_alg_len(const struct xfrm_algo *alg)
{ {
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
} }
static inline int xfrm_alg_auth_len(const struct xfrm_algo_auth *alg) static inline unsigned int xfrm_alg_auth_len(const struct xfrm_algo_auth *alg)
{ {
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
} }
static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay_esn) static inline unsigned int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay_esn)
{ {
return sizeof(*replay_esn) + replay_esn->bmp_len * sizeof(__u32); return sizeof(*replay_esn) + replay_esn->bmp_len * sizeof(__u32);
} }
......
...@@ -483,8 +483,8 @@ static inline int esp_remove_trailer(struct sk_buff *skb) ...@@ -483,8 +483,8 @@ static inline int esp_remove_trailer(struct sk_buff *skb)
goto out; goto out;
} }
if (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2)) ret = skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2);
BUG(); BUG_ON(ret);
ret = -EINVAL; ret = -EINVAL;
padlen = nexthdr[0]; padlen = nexthdr[0];
...@@ -559,14 +559,14 @@ static void esp_input_restore_header(struct sk_buff *skb) ...@@ -559,14 +559,14 @@ static void esp_input_restore_header(struct sk_buff *skb)
static void esp_input_set_header(struct sk_buff *skb, __be32 *seqhi) static void esp_input_set_header(struct sk_buff *skb, __be32 *seqhi)
{ {
struct xfrm_state *x = xfrm_input_state(skb); struct xfrm_state *x = xfrm_input_state(skb);
struct ip_esp_hdr *esph = (struct ip_esp_hdr *)skb->data;
/* For ESN we move the header forward by 4 bytes to /* For ESN we move the header forward by 4 bytes to
* accomodate the high bits. We will move it back after * accomodate the high bits. We will move it back after
* decryption. * decryption.
*/ */
if ((x->props.flags & XFRM_STATE_ESN)) { if ((x->props.flags & XFRM_STATE_ESN)) {
esph = skb_push(skb, 4); struct ip_esp_hdr *esph = skb_push(skb, 4);
*seqhi = esph->spi; *seqhi = esph->spi;
esph->spi = esph->seq_no; esph->spi = esph->seq_no;
esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi; esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi;
......
...@@ -42,7 +42,7 @@ static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type) ...@@ -42,7 +42,7 @@ static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
return 0; return 0;
algp = nla_data(rt); algp = nla_data(rt);
if (nla_len(rt) < xfrm_alg_len(algp)) if (nla_len(rt) < (int)xfrm_alg_len(algp))
return -EINVAL; return -EINVAL;
switch (type) { switch (type) {
...@@ -68,7 +68,7 @@ static int verify_auth_trunc(struct nlattr **attrs) ...@@ -68,7 +68,7 @@ static int verify_auth_trunc(struct nlattr **attrs)
return 0; return 0;
algp = nla_data(rt); algp = nla_data(rt);
if (nla_len(rt) < xfrm_alg_auth_len(algp)) if (nla_len(rt) < (int)xfrm_alg_auth_len(algp))
return -EINVAL; return -EINVAL;
algp->alg_name[sizeof(algp->alg_name) - 1] = '\0'; algp->alg_name[sizeof(algp->alg_name) - 1] = '\0';
...@@ -84,7 +84,7 @@ static int verify_aead(struct nlattr **attrs) ...@@ -84,7 +84,7 @@ static int verify_aead(struct nlattr **attrs)
return 0; return 0;
algp = nla_data(rt); algp = nla_data(rt);
if (nla_len(rt) < aead_len(algp)) if (nla_len(rt) < (int)aead_len(algp))
return -EINVAL; return -EINVAL;
algp->alg_name[sizeof(algp->alg_name) - 1] = '\0'; algp->alg_name[sizeof(algp->alg_name) - 1] = '\0';
...@@ -130,7 +130,7 @@ static inline int verify_replay(struct xfrm_usersa_info *p, ...@@ -130,7 +130,7 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8) if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8)
return -EINVAL; return -EINVAL;
if (nla_len(rt) < xfrm_replay_state_esn_len(rs) && if (nla_len(rt) < (int)xfrm_replay_state_esn_len(rs) &&
nla_len(rt) != sizeof(*rs)) nla_len(rt) != sizeof(*rs))
return -EINVAL; return -EINVAL;
} }
...@@ -404,7 +404,7 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es ...@@ -404,7 +404,7 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
struct nlattr *rp) struct nlattr *rp)
{ {
struct xfrm_replay_state_esn *up; struct xfrm_replay_state_esn *up;
int ulen; unsigned int ulen;
if (!replay_esn || !rp) if (!replay_esn || !rp)
return 0; return 0;
...@@ -414,7 +414,7 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es ...@@ -414,7 +414,7 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
/* Check the overall length and the internal bitmap length to avoid /* Check the overall length and the internal bitmap length to avoid
* potential overflow. */ * potential overflow. */
if (nla_len(rp) < ulen || if (nla_len(rp) < (int)ulen ||
xfrm_replay_state_esn_len(replay_esn) != ulen || xfrm_replay_state_esn_len(replay_esn) != ulen ||
replay_esn->bmp_len != up->bmp_len) replay_esn->bmp_len != up->bmp_len)
return -EINVAL; return -EINVAL;
...@@ -430,14 +430,14 @@ static int xfrm_alloc_replay_state_esn(struct xfrm_replay_state_esn **replay_esn ...@@ -430,14 +430,14 @@ static int xfrm_alloc_replay_state_esn(struct xfrm_replay_state_esn **replay_esn
struct nlattr *rta) struct nlattr *rta)
{ {
struct xfrm_replay_state_esn *p, *pp, *up; struct xfrm_replay_state_esn *p, *pp, *up;
int klen, ulen; unsigned int klen, ulen;
if (!rta) if (!rta)
return 0; return 0;
up = nla_data(rta); up = nla_data(rta);
klen = xfrm_replay_state_esn_len(up); klen = xfrm_replay_state_esn_len(up);
ulen = nla_len(rta) >= klen ? klen : sizeof(*up); ulen = nla_len(rta) >= (int)klen ? klen : sizeof(*up);
p = kzalloc(klen, GFP_KERNEL); p = kzalloc(klen, GFP_KERNEL);
if (!p) if (!p)
...@@ -458,9 +458,9 @@ static int xfrm_alloc_replay_state_esn(struct xfrm_replay_state_esn **replay_esn ...@@ -458,9 +458,9 @@ static int xfrm_alloc_replay_state_esn(struct xfrm_replay_state_esn **replay_esn
return 0; return 0;
} }
static inline int xfrm_user_sec_ctx_size(struct xfrm_sec_ctx *xfrm_ctx) static inline unsigned int xfrm_user_sec_ctx_size(struct xfrm_sec_ctx *xfrm_ctx)
{ {
int len = 0; unsigned int len = 0;
if (xfrm_ctx) { if (xfrm_ctx) {
len += sizeof(struct xfrm_user_sec_ctx); len += sizeof(struct xfrm_user_sec_ctx);
...@@ -1032,7 +1032,7 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb, ...@@ -1032,7 +1032,7 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb,
return -1; return -1;
} }
static inline size_t xfrm_spdinfo_msgsize(void) static inline unsigned int xfrm_spdinfo_msgsize(void)
{ {
return NLMSG_ALIGN(4) return NLMSG_ALIGN(4)
+ nla_total_size(sizeof(struct xfrmu_spdinfo)) + nla_total_size(sizeof(struct xfrmu_spdinfo))
...@@ -1147,18 +1147,19 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1147,18 +1147,19 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
u32 *flags = nlmsg_data(nlh); u32 *flags = nlmsg_data(nlh);
u32 sportid = NETLINK_CB(skb).portid; u32 sportid = NETLINK_CB(skb).portid;
u32 seq = nlh->nlmsg_seq; u32 seq = nlh->nlmsg_seq;
int err;
r_skb = nlmsg_new(xfrm_spdinfo_msgsize(), GFP_ATOMIC); r_skb = nlmsg_new(xfrm_spdinfo_msgsize(), GFP_ATOMIC);
if (r_skb == NULL) if (r_skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_spdinfo(r_skb, net, sportid, seq, *flags) < 0) err = build_spdinfo(r_skb, net, sportid, seq, *flags);
BUG(); BUG_ON(err < 0);
return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid); return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);
} }
static inline size_t xfrm_sadinfo_msgsize(void) static inline unsigned int xfrm_sadinfo_msgsize(void)
{ {
return NLMSG_ALIGN(4) return NLMSG_ALIGN(4)
+ nla_total_size(sizeof(struct xfrmu_sadhinfo)) + nla_total_size(sizeof(struct xfrmu_sadhinfo))
...@@ -1205,13 +1206,14 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1205,13 +1206,14 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
u32 *flags = nlmsg_data(nlh); u32 *flags = nlmsg_data(nlh);
u32 sportid = NETLINK_CB(skb).portid; u32 sportid = NETLINK_CB(skb).portid;
u32 seq = nlh->nlmsg_seq; u32 seq = nlh->nlmsg_seq;
int err;
r_skb = nlmsg_new(xfrm_sadinfo_msgsize(), GFP_ATOMIC); r_skb = nlmsg_new(xfrm_sadinfo_msgsize(), GFP_ATOMIC);
if (r_skb == NULL) if (r_skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_sadinfo(r_skb, net, sportid, seq, *flags) < 0) err = build_sadinfo(r_skb, net, sportid, seq, *flags);
BUG(); BUG_ON(err < 0);
return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid); return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);
} }
...@@ -1634,7 +1636,7 @@ static inline int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *s ...@@ -1634,7 +1636,7 @@ static inline int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *s
return copy_sec_ctx(xp->security, skb); return copy_sec_ctx(xp->security, skb);
return 0; return 0;
} }
static inline size_t userpolicy_type_attrsize(void) static inline unsigned int userpolicy_type_attrsize(void)
{ {
#ifdef CONFIG_XFRM_SUB_POLICY #ifdef CONFIG_XFRM_SUB_POLICY
return nla_total_size(sizeof(struct xfrm_userpolicy_type)); return nla_total_size(sizeof(struct xfrm_userpolicy_type));
...@@ -1853,9 +1855,9 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1853,9 +1855,9 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
return 0; return 0;
} }
static inline size_t xfrm_aevent_msgsize(struct xfrm_state *x) static inline unsigned int xfrm_aevent_msgsize(struct xfrm_state *x)
{ {
size_t replay_size = x->replay_esn ? unsigned int replay_size = x->replay_esn ?
xfrm_replay_state_esn_len(x->replay_esn) : xfrm_replay_state_esn_len(x->replay_esn) :
sizeof(struct xfrm_replay_state); sizeof(struct xfrm_replay_state);
...@@ -1960,8 +1962,9 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1960,8 +1962,9 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
c.seq = nlh->nlmsg_seq; c.seq = nlh->nlmsg_seq;
c.portid = nlh->nlmsg_pid; c.portid = nlh->nlmsg_pid;
if (build_aevent(r_skb, x, &c) < 0) err = build_aevent(r_skb, x, &c);
BUG(); BUG_ON(err < 0);
err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid); err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid);
spin_unlock_bh(&x->lock); spin_unlock_bh(&x->lock);
xfrm_state_put(x); xfrm_state_put(x);
...@@ -2324,7 +2327,7 @@ static int copy_to_user_kmaddress(const struct xfrm_kmaddress *k, struct sk_buff ...@@ -2324,7 +2327,7 @@ static int copy_to_user_kmaddress(const struct xfrm_kmaddress *k, struct sk_buff
return nla_put(skb, XFRMA_KMADDRESS, sizeof(uk), &uk); return nla_put(skb, XFRMA_KMADDRESS, sizeof(uk), &uk);
} }
static inline size_t xfrm_migrate_msgsize(int num_migrate, int with_kma, static inline unsigned int xfrm_migrate_msgsize(int num_migrate, int with_kma,
int with_encp) int with_encp)
{ {
return NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_id)) return NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_id))
...@@ -2388,6 +2391,7 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, ...@@ -2388,6 +2391,7 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
{ {
struct net *net = &init_net; struct net *net = &init_net;
struct sk_buff *skb; struct sk_buff *skb;
int err;
skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k, !!encap), skb = nlmsg_new(xfrm_migrate_msgsize(num_migrate, !!k, !!encap),
GFP_ATOMIC); GFP_ATOMIC);
...@@ -2395,8 +2399,8 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, ...@@ -2395,8 +2399,8 @@ static int xfrm_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
return -ENOMEM; return -ENOMEM;
/* build migrate */ /* build migrate */
if (build_migrate(skb, m, num_migrate, k, sel, encap, dir, type) < 0) err = build_migrate(skb, m, num_migrate, k, sel, encap, dir, type);
BUG(); BUG_ON(err < 0);
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MIGRATE); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MIGRATE);
} }
...@@ -2572,7 +2576,7 @@ static void xfrm_netlink_rcv(struct sk_buff *skb) ...@@ -2572,7 +2576,7 @@ static void xfrm_netlink_rcv(struct sk_buff *skb)
mutex_unlock(&net->xfrm.xfrm_cfg_mutex); mutex_unlock(&net->xfrm.xfrm_cfg_mutex);
} }
static inline size_t xfrm_expire_msgsize(void) static inline unsigned int xfrm_expire_msgsize(void)
{ {
return NLMSG_ALIGN(sizeof(struct xfrm_user_expire)) return NLMSG_ALIGN(sizeof(struct xfrm_user_expire))
+ nla_total_size(sizeof(struct xfrm_mark)); + nla_total_size(sizeof(struct xfrm_mark));
...@@ -2623,13 +2627,14 @@ static int xfrm_aevent_state_notify(struct xfrm_state *x, const struct km_event ...@@ -2623,13 +2627,14 @@ static int xfrm_aevent_state_notify(struct xfrm_state *x, const struct km_event
{ {
struct net *net = xs_net(x); struct net *net = xs_net(x);
struct sk_buff *skb; struct sk_buff *skb;
int err;
skb = nlmsg_new(xfrm_aevent_msgsize(x), GFP_ATOMIC); skb = nlmsg_new(xfrm_aevent_msgsize(x), GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_aevent(skb, x, c) < 0) err = build_aevent(skb, x, c);
BUG(); BUG_ON(err < 0);
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_AEVENTS); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_AEVENTS);
} }
...@@ -2660,9 +2665,9 @@ static int xfrm_notify_sa_flush(const struct km_event *c) ...@@ -2660,9 +2665,9 @@ static int xfrm_notify_sa_flush(const struct km_event *c)
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_SA); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_SA);
} }
static inline size_t xfrm_sa_len(struct xfrm_state *x) static inline unsigned int xfrm_sa_len(struct xfrm_state *x)
{ {
size_t l = 0; unsigned int l = 0;
if (x->aead) if (x->aead)
l += nla_total_size(aead_len(x->aead)); l += nla_total_size(aead_len(x->aead));
if (x->aalg) { if (x->aalg) {
...@@ -2707,8 +2712,9 @@ static int xfrm_notify_sa(struct xfrm_state *x, const struct km_event *c) ...@@ -2707,8 +2712,9 @@ static int xfrm_notify_sa(struct xfrm_state *x, const struct km_event *c)
struct xfrm_usersa_id *id; struct xfrm_usersa_id *id;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
struct sk_buff *skb; struct sk_buff *skb;
int len = xfrm_sa_len(x); unsigned int len = xfrm_sa_len(x);
int headlen, err; unsigned int headlen;
int err;
headlen = sizeof(*p); headlen = sizeof(*p);
if (c->event == XFRM_MSG_DELSA) { if (c->event == XFRM_MSG_DELSA) {
...@@ -2782,7 +2788,7 @@ static int xfrm_send_state_notify(struct xfrm_state *x, const struct km_event *c ...@@ -2782,7 +2788,7 @@ static int xfrm_send_state_notify(struct xfrm_state *x, const struct km_event *c
} }
static inline size_t xfrm_acquire_msgsize(struct xfrm_state *x, static inline unsigned int xfrm_acquire_msgsize(struct xfrm_state *x,
struct xfrm_policy *xp) struct xfrm_policy *xp)
{ {
return NLMSG_ALIGN(sizeof(struct xfrm_user_acquire)) return NLMSG_ALIGN(sizeof(struct xfrm_user_acquire))
...@@ -2835,13 +2841,14 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, ...@@ -2835,13 +2841,14 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
{ {
struct net *net = xs_net(x); struct net *net = xs_net(x);
struct sk_buff *skb; struct sk_buff *skb;
int err;
skb = nlmsg_new(xfrm_acquire_msgsize(x, xp), GFP_ATOMIC); skb = nlmsg_new(xfrm_acquire_msgsize(x, xp), GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_acquire(skb, x, xt, xp) < 0) err = build_acquire(skb, x, xt, xp);
BUG(); BUG_ON(err < 0);
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_ACQUIRE); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_ACQUIRE);
} }
...@@ -2906,7 +2913,7 @@ static struct xfrm_policy *xfrm_compile_policy(struct sock *sk, int opt, ...@@ -2906,7 +2913,7 @@ static struct xfrm_policy *xfrm_compile_policy(struct sock *sk, int opt,
return xp; return xp;
} }
static inline size_t xfrm_polexpire_msgsize(struct xfrm_policy *xp) static inline unsigned int xfrm_polexpire_msgsize(struct xfrm_policy *xp)
{ {
return NLMSG_ALIGN(sizeof(struct xfrm_user_polexpire)) return NLMSG_ALIGN(sizeof(struct xfrm_user_polexpire))
+ nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr) + nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr)
...@@ -2950,26 +2957,28 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, const struct ...@@ -2950,26 +2957,28 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, const struct
{ {
struct net *net = xp_net(xp); struct net *net = xp_net(xp);
struct sk_buff *skb; struct sk_buff *skb;
int err;
skb = nlmsg_new(xfrm_polexpire_msgsize(xp), GFP_ATOMIC); skb = nlmsg_new(xfrm_polexpire_msgsize(xp), GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_polexpire(skb, xp, dir, c) < 0) err = build_polexpire(skb, xp, dir, c);
BUG(); BUG_ON(err < 0);
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_EXPIRE); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_EXPIRE);
} }
static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, const struct km_event *c) static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, const struct km_event *c)
{ {
int len = nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); unsigned int len = nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
struct net *net = xp_net(xp); struct net *net = xp_net(xp);
struct xfrm_userpolicy_info *p; struct xfrm_userpolicy_info *p;
struct xfrm_userpolicy_id *id; struct xfrm_userpolicy_id *id;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
struct sk_buff *skb; struct sk_buff *skb;
int headlen, err; unsigned int headlen;
int err;
headlen = sizeof(*p); headlen = sizeof(*p);
if (c->event == XFRM_MSG_DELPOLICY) { if (c->event == XFRM_MSG_DELPOLICY) {
...@@ -3076,7 +3085,7 @@ static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, const struct ...@@ -3076,7 +3085,7 @@ static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, const struct
} }
static inline size_t xfrm_report_msgsize(void) static inline unsigned int xfrm_report_msgsize(void)
{ {
return NLMSG_ALIGN(sizeof(struct xfrm_user_report)); return NLMSG_ALIGN(sizeof(struct xfrm_user_report));
} }
...@@ -3110,18 +3119,19 @@ static int xfrm_send_report(struct net *net, u8 proto, ...@@ -3110,18 +3119,19 @@ static int xfrm_send_report(struct net *net, u8 proto,
struct xfrm_selector *sel, xfrm_address_t *addr) struct xfrm_selector *sel, xfrm_address_t *addr)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int err;
skb = nlmsg_new(xfrm_report_msgsize(), GFP_ATOMIC); skb = nlmsg_new(xfrm_report_msgsize(), GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_report(skb, proto, sel, addr) < 0) err = build_report(skb, proto, sel, addr);
BUG(); BUG_ON(err < 0);
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_REPORT); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_REPORT);
} }
static inline size_t xfrm_mapping_msgsize(void) static inline unsigned int xfrm_mapping_msgsize(void)
{ {
return NLMSG_ALIGN(sizeof(struct xfrm_user_mapping)); return NLMSG_ALIGN(sizeof(struct xfrm_user_mapping));
} }
...@@ -3157,6 +3167,7 @@ static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, ...@@ -3157,6 +3167,7 @@ static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
{ {
struct net *net = xs_net(x); struct net *net = xs_net(x);
struct sk_buff *skb; struct sk_buff *skb;
int err;
if (x->id.proto != IPPROTO_ESP) if (x->id.proto != IPPROTO_ESP)
return -EINVAL; return -EINVAL;
...@@ -3168,8 +3179,8 @@ static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, ...@@ -3168,8 +3179,8 @@ static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_mapping(skb, x, ipaddr, sport) < 0) err = build_mapping(skb, x, ipaddr, sport);
BUG(); BUG_ON(err < 0);
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MAPPING); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MAPPING);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment