diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-03 14:55:33 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-03 14:55:33 +0200 |
commit | 905839bff398d8ce6d050ee766413fa0c7b5d02c (patch) | |
tree | 01f377b6cf47772dd53ae87ae39b1c8b2011f03a /src/netlink.c | |
parent | global: use _WG prefix for include guards (diff) | |
download | wireguard-monolithic-historical-905839bff398d8ce6d050ee766413fa0c7b5d02c.tar.xz wireguard-monolithic-historical-905839bff398d8ce6d050ee766413fa0c7b5d02c.zip |
global: add space around variable declarations
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c index 84ca850..8734ddd 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -70,6 +70,7 @@ static int get_allowedips(void *ctx, union nf_inet_addr ip, u8 cidr, int family) { struct nlattr *allowedip_nest; struct allowedips_ctx *actx = ctx; + if (++actx->idx < actx->idx_cursor) return 0; allowedip_nest = nla_nest_start(actx->skb, actx->idx - 1); @@ -91,6 +92,7 @@ static int get_peer(struct wireguard_peer *peer, unsigned int index, unsigned in struct allowedips_ctx ctx = { .skb = skb, .idx_cursor = *allowedips_idx_cursor }; struct nlattr *allowedips_nest, *peer_nest = nla_nest_start(skb, index); bool fail; + if (!peer_nest) return -EMSGSIZE; @@ -144,6 +146,7 @@ static int get_start(struct netlink_callback *cb) struct wireguard_device *wg; struct nlattr **attrs = genl_family_attrbuf(&genl_family); int ret = nlmsg_parse(cb->nlh, GENL_HDRLEN + genl_family.hdrsize, attrs, genl_family.maxattr, device_policy, NULL); + if (ret < 0) return ret; wg = lookup_interface(attrs, cb->skb); @@ -246,6 +249,7 @@ static int get_done(struct netlink_callback *cb) { struct wireguard_device *wg = (struct wireguard_device *)cb->args[0]; struct wireguard_peer *peer = (struct wireguard_peer *)cb->args[1]; + if (wg) dev_put(wg->dev); peer_put(peer); @@ -255,6 +259,7 @@ static int get_done(struct netlink_callback *cb) static int set_device_port(struct wireguard_device *wg, u16 port) { struct wireguard_peer *peer, *temp; + if (wg->incoming_port == port) return 0; socket_uninit(wg); @@ -384,6 +389,7 @@ static int set(struct sk_buff *skb, struct genl_info *info) { int ret; struct wireguard_device *wg = lookup_interface(info->attrs, skb); + if (IS_ERR(wg)) { ret = PTR_ERR(wg); goto out_nodev; |