diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-05 22:59:40 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-05 22:59:40 +0200 |
commit | c211f7d1e2c27e22e11581bef5a847582b26c08b (patch) | |
tree | 0b4be584f3dffab7baf153e51c09f161742fdc8c /src/netlink.c | |
parent | Makefile: clang now builds the kernel, so use scan-build (diff) | |
download | wireguard-monolithic-historical-c211f7d1e2c27e22e11581bef5a847582b26c08b.tar.xz wireguard-monolithic-historical-c211f7d1e2c27e22e11581bef5a847582b26c08b.zip |
compat: macro rewrite netlink instead of cluttering
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/netlink.c b/src/netlink.c index 8734ddd..b813508 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -141,7 +141,7 @@ err: return -EMSGSIZE; } -static int get_start(struct netlink_callback *cb) +static int get_device_start(struct netlink_callback *cb) { struct wireguard_device *wg; struct nlattr **attrs = genl_family_attrbuf(&genl_family); @@ -156,7 +156,7 @@ static int get_start(struct netlink_callback *cb) return 0; } -static int get(struct sk_buff *skb, struct netlink_callback *cb) +static int get_device_dump(struct sk_buff *skb, struct netlink_callback *cb) { struct wireguard_device *wg = (struct wireguard_device *)cb->args[0]; struct wireguard_peer *peer, *next_peer_cursor = NULL, *last_peer_cursor = (struct wireguard_peer *)cb->args[1]; @@ -166,15 +166,6 @@ static int get(struct sk_buff *skb, struct netlink_callback *cb) void *hdr; int ret = -EMSGSIZE; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) - if (!wg) { - ret = get_start(cb); - if (ret) - return ret; - return get(skb, cb); - } -#endif - rtnl_lock(); mutex_lock(&wg->device_update_lock); cb->seq = wg->device_update_gen; @@ -245,7 +236,7 @@ out: * in the kernel for marking skbs as zero_on_free. */ } -static int get_done(struct netlink_callback *cb) +static int get_device_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]; @@ -256,7 +247,7 @@ static int get_done(struct netlink_callback *cb) return 0; } -static int set_device_port(struct wireguard_device *wg, u16 port) +static int set_port(struct wireguard_device *wg, u16 port) { struct wireguard_peer *peer, *temp; @@ -385,7 +376,7 @@ out: return ret; } -static int set(struct sk_buff *skb, struct genl_info *info) +static int set_device(struct sk_buff *skb, struct genl_info *info) { int ret; struct wireguard_device *wg = lookup_interface(info->attrs, skb); @@ -407,7 +398,7 @@ static int set(struct sk_buff *skb, struct genl_info *info) } if (info->attrs[WGDEVICE_A_LISTEN_PORT]) { - ret = set_device_port(wg, nla_get_u16(info->attrs[WGDEVICE_A_LISTEN_PORT])); + ret = set_port(wg, nla_get_u16(info->attrs[WGDEVICE_A_LISTEN_PORT])); if (ret) goto out; } @@ -461,15 +452,15 @@ static const struct genl_ops genl_ops[] = { { .cmd = WG_CMD_GET_DEVICE, #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) - .start = get_start, + .start = get_device_start, #endif - .dumpit = get, - .done = get_done, + .dumpit = get_device_dump, + .done = get_device_done, .policy = device_policy, .flags = GENL_UNS_ADMIN_PERM }, { .cmd = WG_CMD_SET_DEVICE, - .doit = set, + .doit = set_device, .policy = device_policy, .flags = GENL_UNS_ADMIN_PERM } |