netlink: do not stuff index into nla type
It's not used for anything, and LKML doesn't like the type being used as an index value. Suggested-by: Eugene Syromiatnikov <esyr@redhat.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
6790b07868
commit
54569b7999
|
@ -1074,7 +1074,6 @@ cleanup:
|
||||||
int wg_set_device(wg_device *dev)
|
int wg_set_device(wg_device *dev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
size_t i, j;
|
|
||||||
wg_peer *peer = NULL;
|
wg_peer *peer = NULL;
|
||||||
wg_allowedip *allowedip = NULL;
|
wg_allowedip *allowedip = NULL;
|
||||||
struct nlattr *peers_nest, *peer_nest, *allowedips_nest, *allowedip_nest;
|
struct nlattr *peers_nest, *peer_nest, *allowedips_nest, *allowedip_nest;
|
||||||
|
@ -1107,10 +1106,10 @@ again:
|
||||||
goto send;
|
goto send;
|
||||||
peers_nest = peer_nest = allowedips_nest = allowedip_nest = NULL;
|
peers_nest = peer_nest = allowedips_nest = allowedip_nest = NULL;
|
||||||
peers_nest = mnl_attr_nest_start(nlh, WGDEVICE_A_PEERS);
|
peers_nest = mnl_attr_nest_start(nlh, WGDEVICE_A_PEERS);
|
||||||
for (i = 0, peer = peer ? peer : dev->first_peer; peer; peer = peer->next_peer) {
|
for (peer = peer ? peer : dev->first_peer; peer; peer = peer->next_peer) {
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
|
||||||
peer_nest = mnl_attr_nest_start_check(nlh, MNL_SOCKET_BUFFER_SIZE, i++);
|
peer_nest = mnl_attr_nest_start_check(nlh, MNL_SOCKET_BUFFER_SIZE, 0);
|
||||||
if (!peer_nest)
|
if (!peer_nest)
|
||||||
goto toobig_peers;
|
goto toobig_peers;
|
||||||
if (!mnl_attr_put_check(nlh, MNL_SOCKET_BUFFER_SIZE, WGPEER_A_PUBLIC_KEY, sizeof(peer->public_key), peer->public_key))
|
if (!mnl_attr_put_check(nlh, MNL_SOCKET_BUFFER_SIZE, WGPEER_A_PUBLIC_KEY, sizeof(peer->public_key), peer->public_key))
|
||||||
|
@ -1146,8 +1145,8 @@ again:
|
||||||
allowedips_nest = mnl_attr_nest_start_check(nlh, MNL_SOCKET_BUFFER_SIZE, WGPEER_A_ALLOWEDIPS);
|
allowedips_nest = mnl_attr_nest_start_check(nlh, MNL_SOCKET_BUFFER_SIZE, WGPEER_A_ALLOWEDIPS);
|
||||||
if (!allowedips_nest)
|
if (!allowedips_nest)
|
||||||
goto toobig_allowedips;
|
goto toobig_allowedips;
|
||||||
for (j = 0; allowedip; allowedip = allowedip->next_allowedip) {
|
for (; allowedip; allowedip = allowedip->next_allowedip) {
|
||||||
allowedip_nest = mnl_attr_nest_start_check(nlh, MNL_SOCKET_BUFFER_SIZE, j++);
|
allowedip_nest = mnl_attr_nest_start_check(nlh, MNL_SOCKET_BUFFER_SIZE, 0);
|
||||||
if (!allowedip_nest)
|
if (!allowedip_nest)
|
||||||
goto toobig_allowedips;
|
goto toobig_allowedips;
|
||||||
if (!mnl_attr_put_u16_check(nlh, MNL_SOCKET_BUFFER_SIZE, WGALLOWEDIP_A_FAMILY, allowedip->family))
|
if (!mnl_attr_put_u16_check(nlh, MNL_SOCKET_BUFFER_SIZE, WGALLOWEDIP_A_FAMILY, allowedip->family))
|
||||||
|
|
|
@ -547,7 +547,6 @@ cleanup:
|
||||||
static int kernel_set_device(struct wgdevice *dev)
|
static int kernel_set_device(struct wgdevice *dev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
size_t i, j;
|
|
||||||
struct wgpeer *peer = NULL;
|
struct wgpeer *peer = NULL;
|
||||||
struct wgallowedip *allowedip = NULL;
|
struct wgallowedip *allowedip = NULL;
|
||||||
struct nlattr *peers_nest, *peer_nest, *allowedips_nest, *allowedip_nest;
|
struct nlattr *peers_nest, *peer_nest, *allowedips_nest, *allowedip_nest;
|
||||||
|
@ -580,10 +579,10 @@ again:
|
||||||
goto send;
|
goto send;
|
||||||
peers_nest = peer_nest = allowedips_nest = allowedip_nest = NULL;
|
peers_nest = peer_nest = allowedips_nest = allowedip_nest = NULL;
|
||||||
peers_nest = mnl_attr_nest_start(nlh, WGDEVICE_A_PEERS);
|
peers_nest = mnl_attr_nest_start(nlh, WGDEVICE_A_PEERS);
|
||||||
for (i = 0, peer = peer ? peer : dev->first_peer; peer; peer = peer->next_peer) {
|
for (peer = peer ? peer : dev->first_peer; peer; peer = peer->next_peer) {
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
|
||||||
peer_nest = mnl_attr_nest_start_check(nlh, SOCKET_BUFFER_SIZE, i++);
|
peer_nest = mnl_attr_nest_start_check(nlh, SOCKET_BUFFER_SIZE, 0);
|
||||||
if (!peer_nest)
|
if (!peer_nest)
|
||||||
goto toobig_peers;
|
goto toobig_peers;
|
||||||
if (!mnl_attr_put_check(nlh, SOCKET_BUFFER_SIZE, WGPEER_A_PUBLIC_KEY, sizeof(peer->public_key), peer->public_key))
|
if (!mnl_attr_put_check(nlh, SOCKET_BUFFER_SIZE, WGPEER_A_PUBLIC_KEY, sizeof(peer->public_key), peer->public_key))
|
||||||
|
@ -619,8 +618,8 @@ again:
|
||||||
allowedips_nest = mnl_attr_nest_start_check(nlh, SOCKET_BUFFER_SIZE, WGPEER_A_ALLOWEDIPS);
|
allowedips_nest = mnl_attr_nest_start_check(nlh, SOCKET_BUFFER_SIZE, WGPEER_A_ALLOWEDIPS);
|
||||||
if (!allowedips_nest)
|
if (!allowedips_nest)
|
||||||
goto toobig_allowedips;
|
goto toobig_allowedips;
|
||||||
for (j = 0; allowedip; allowedip = allowedip->next_allowedip) {
|
for (; allowedip; allowedip = allowedip->next_allowedip) {
|
||||||
allowedip_nest = mnl_attr_nest_start_check(nlh, SOCKET_BUFFER_SIZE, j++);
|
allowedip_nest = mnl_attr_nest_start_check(nlh, SOCKET_BUFFER_SIZE, 0);
|
||||||
if (!allowedip_nest)
|
if (!allowedip_nest)
|
||||||
goto toobig_allowedips;
|
goto toobig_allowedips;
|
||||||
if (!mnl_attr_put_u16_check(nlh, SOCKET_BUFFER_SIZE, WGALLOWEDIP_A_FAMILY, allowedip->family))
|
if (!mnl_attr_put_u16_check(nlh, SOCKET_BUFFER_SIZE, WGALLOWEDIP_A_FAMILY, allowedip->family))
|
||||||
|
|
Loading…
Reference in a new issue