@@ -24,7 +24,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = {
2424 [WGDEVICE_A_IFNAME ] = { .type = NLA_NUL_STRING , .len = IFNAMSIZ - 1 },
2525 [WGDEVICE_A_PRIVATE_KEY ] = NLA_POLICY_EXACT_LEN (NOISE_PUBLIC_KEY_LEN ),
2626 [WGDEVICE_A_PUBLIC_KEY ] = NLA_POLICY_EXACT_LEN (NOISE_PUBLIC_KEY_LEN ),
27- [WGDEVICE_A_FLAGS ] = { . type = NLA_U32 } ,
27+ [WGDEVICE_A_FLAGS ] = NLA_POLICY_MASK ( NLA_U32 , __WGDEVICE_F_ALL ) ,
2828 [WGDEVICE_A_LISTEN_PORT ] = { .type = NLA_U16 },
2929 [WGDEVICE_A_FWMARK ] = { .type = NLA_U32 },
3030 [WGDEVICE_A_PEERS ] = { .type = NLA_NESTED }
@@ -33,7 +33,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = {
3333static const struct nla_policy peer_policy [WGPEER_A_MAX + 1 ] = {
3434 [WGPEER_A_PUBLIC_KEY ] = NLA_POLICY_EXACT_LEN (NOISE_PUBLIC_KEY_LEN ),
3535 [WGPEER_A_PRESHARED_KEY ] = NLA_POLICY_EXACT_LEN (NOISE_SYMMETRIC_KEY_LEN ),
36- [WGPEER_A_FLAGS ] = { . type = NLA_U32 } ,
36+ [WGPEER_A_FLAGS ] = NLA_POLICY_MASK ( NLA_U32 , __WGPEER_F_ALL ) ,
3737 [WGPEER_A_ENDPOINT ] = NLA_POLICY_MIN_LEN (sizeof (struct sockaddr )),
3838 [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL ] = { .type = NLA_U16 },
3939 [WGPEER_A_LAST_HANDSHAKE_TIME ] = NLA_POLICY_EXACT_LEN (sizeof (struct __kernel_timespec )),
@@ -373,9 +373,6 @@ static int set_peer(struct wg_device *wg, struct nlattr **attrs)
373373
374374 if (attrs [WGPEER_A_FLAGS ])
375375 flags = nla_get_u32 (attrs [WGPEER_A_FLAGS ]);
376- ret = - EOPNOTSUPP ;
377- if (flags & ~__WGPEER_F_ALL )
378- goto out ;
379376
380377 ret = - EPFNOSUPPORT ;
381378 if (attrs [WGPEER_A_PROTOCOL_VERSION ]) {
@@ -506,9 +503,6 @@ static int wg_set_device(struct sk_buff *skb, struct genl_info *info)
506503
507504 if (info -> attrs [WGDEVICE_A_FLAGS ])
508505 flags = nla_get_u32 (info -> attrs [WGDEVICE_A_FLAGS ]);
509- ret = - EOPNOTSUPP ;
510- if (flags & ~__WGDEVICE_F_ALL )
511- goto out ;
512506
513507 if (info -> attrs [WGDEVICE_A_LISTEN_PORT ] || info -> attrs [WGDEVICE_A_FWMARK ]) {
514508 struct net * net ;
0 commit comments