WireGuard Archive on lore.kernel.org
 help / Atom feed
* [PATCH] contrib: handles peer version in embed-wireguard
@ 2018-12-03 23:15 Gawen ARAB
  2018-12-05 15:59 ` Gawen ARAB
  2018-12-07  4:36 ` Jason A. Donenfeld
  0 siblings, 2 replies; 3+ messages in thread
From: Gawen ARAB @ 2018-12-03 23:15 UTC (permalink / raw)
  To: wireguard

Commit bc84ba3a inserted a peer version placeholder. Embeddable
wireguard did not handle the flag WGPEER_A_PROTOCOL_VERSION and printed
the following warning:

    Warning: one or more unrecognized netlink attributes

This commit adds the field 'protocol_version' to the structure
'wg_peer'. It is equal to 0 if no protocol version were defined.
---
 contrib/examples/embeddable-wg-library/wireguard.c | 5 +++++
 contrib/examples/embeddable-wg-library/wireguard.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/contrib/examples/embeddable-wg-library/wireguard.c
b/contrib/examples/embeddable-wg-library/wireguard.c
index f0bdb5f..9610c50 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.c
+++ b/contrib/examples/embeddable-wg-library/wireguard.c
@@ -66,6 +66,7 @@ enum wgpeer_attribute {
        WGPEER_A_RX_BYTES,
        WGPEER_A_TX_BYTES,
        WGPEER_A_ALLOWEDIPS,
+       WGPEER_A_PROTOCOL_VERSION,
        __WGPEER_A_LAST
 };

@@ -1326,6 +1327,10 @@ static int parse_peer(const struct nlattr
*attr, void *data)
                break;
        case WGPEER_A_ALLOWEDIPS:
                return mnl_attr_parse_nested(attr, parse_allowedips, peer);
+       case WGPEER_A_PROTOCOL_VERSION:
+               if (!mnl_attr_validate(attr, MNL_TYPE_U32))
+                       peer->protocol_version = mnl_attr_get_u32(attr);
+               break;
        default:
                warn_unrecognized("netlink");
        }
diff --git a/contrib/examples/embeddable-wg-library/wireguard.h
b/contrib/examples/embeddable-wg-library/wireguard.h
index e9210a4..2cee9ac 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.h
+++ b/contrib/examples/embeddable-wg-library/wireguard.h
@@ -49,6 +49,7 @@ typedef struct wg_peer {
        struct timespec last_handshake_time;
        uint64_t rx_bytes, tx_bytes;
        uint16_t persistent_keepalive_interval;
+       uint32_t protocol_version;

        struct wg_allowedip *first_allowedip, *last_allowedip;
        struct wg_peer *next_peer;
--
2.19.2
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] contrib: handles peer version in embed-wireguard
  2018-12-03 23:15 [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
@ 2018-12-05 15:59 ` Gawen ARAB
  2018-12-07  4:36 ` Jason A. Donenfeld
  1 sibling, 0 replies; 3+ messages in thread
From: Gawen ARAB @ 2018-12-05 15:59 UTC (permalink / raw)
  To: wireguard

[-- Attachment #1.1: Type: text/plain, Size: 2019 bytes --]

Commit bc84ba3a inserted a peer version placeholder. Embeddable
wireguard did not handle the flag WGPEER_A_PROTOCOL_VERSION and printed
the following warning:

    Warning: one or more unrecognized netlink attributes

This commit adds the field 'protocol_version' to the structure
'wg_peer'. It is equal to 0 if no protocol version were defined.
---
 contrib/examples/embeddable-wg-library/wireguard.c | 5 +++++
 contrib/examples/embeddable-wg-library/wireguard.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/contrib/examples/embeddable-wg-library/wireguard.c
b/contrib/examples/embeddable-wg-library/wireguard.c
index f0bdb5f..9610c50 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.c
+++ b/contrib/examples/embeddable-wg-library/wireguard.c
@@ -66,6 +66,7 @@ enum wgpeer_attribute {
        WGPEER_A_RX_BYTES,
        WGPEER_A_TX_BYTES,
        WGPEER_A_ALLOWEDIPS,
+       WGPEER_A_PROTOCOL_VERSION,
        __WGPEER_A_LAST
 };

@@ -1326,6 +1327,10 @@ static int parse_peer(const struct nlattr
*attr, void *data)
                break;
        case WGPEER_A_ALLOWEDIPS:
                return mnl_attr_parse_nested(attr, parse_allowedips, peer);
+       case WGPEER_A_PROTOCOL_VERSION:
+               if (!mnl_attr_validate(attr, MNL_TYPE_U32))
+                       peer->protocol_version = mnl_attr_get_u32(attr);
+               break;
        default:
                warn_unrecognized("netlink");
        }
diff --git a/contrib/examples/embeddable-wg-library/wireguard.h
b/contrib/examples/embeddable-wg-library/wireguard.h
index e9210a4..2cee9ac 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.h
+++ b/contrib/examples/embeddable-wg-library/wireguard.h
@@ -49,6 +49,7 @@ typedef struct wg_peer {
        struct timespec last_handshake_time;
        uint64_t rx_bytes, tx_bytes;
        uint16_t persistent_keepalive_interval;
+       uint32_t protocol_version;

        struct wg_allowedip *first_allowedip, *last_allowedip;
        struct wg_peer *next_peer;
--
2.19.2

[-- Attachment #1.2: Type: text/html, Size: 2518 bytes --]

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib: handles peer version in embed-wireguard
  2018-12-03 23:15 [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
  2018-12-05 15:59 ` Gawen ARAB
@ 2018-12-07  4:36 ` Jason A. Donenfeld
  1 sibling, 0 replies; 3+ messages in thread
From: Jason A. Donenfeld @ 2018-12-07  4:36 UTC (permalink / raw)
  To: g; +Cc: WireGuard mailing list

Thanks. Fixed there in the same way it was earlier in src/tools/.
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 23:15 [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
2018-12-05 15:59 ` Gawen ARAB
2018-12-07  4:36 ` Jason A. Donenfeld

WireGuard Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/wireguard/0 wireguard/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 wireguard wireguard/ https://lore.kernel.org/wireguard \
		wireguard@lists.zx2c4.com zx2c4-wireguard@archiver.kernel.org
	public-inbox-index wireguard


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.zx2c4.lists.wireguard


AGPL code for this site: git clone https://public-inbox.org/ public-inbox