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 --]

<div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr">Commit bc84ba3a inserted a peer version placeholder. Embeddable<br></div>
wireguard did not handle the flag WGPEER_A_PROTOCOL_VERSION and printed<br>
the following warning:<br>
<br>
    Warning: one or more unrecognized netlink attributes<br>
<br>
This commit adds the field &#39;protocol_version&#39; to the structure<br>
&#39;wg_peer&#39;. It is equal to 0 if no protocol version were defined.<br>
---<br>
 contrib/examples/embeddable-wg-library/wireguard.c | 5 +++++<br>
 contrib/examples/embeddable-wg-library/wireguard.h | 1 +<br>
 2 files changed, 6 insertions(+)<br>
<br>
diff --git a/contrib/examples/embeddable-wg-library/wireguard.c<br>
b/contrib/examples/embeddable-wg-library/wireguard.c<br>
index f0bdb5f..9610c50 100644<br>
--- a/contrib/examples/embeddable-wg-library/wireguard.c<br>
+++ b/contrib/examples/embeddable-wg-library/wireguard.c<br>
@@ -66,6 +66,7 @@ enum wgpeer_attribute {<br>
        WGPEER_A_RX_BYTES,<br>
        WGPEER_A_TX_BYTES,<br>
        WGPEER_A_ALLOWEDIPS,<br>
+       WGPEER_A_PROTOCOL_VERSION,<br>
        __WGPEER_A_LAST<br>
 };<br>
<br>
@@ -1326,6 +1327,10 @@ static int parse_peer(const struct nlattr<br>
*attr, void *data)<br>
                break;<br>
        case WGPEER_A_ALLOWEDIPS:<br>
                return mnl_attr_parse_nested(attr, parse_allowedips, peer);<br>
+       case WGPEER_A_PROTOCOL_VERSION:<br>
+               if (!mnl_attr_validate(attr, MNL_TYPE_U32))<br>
+                       peer-&gt;protocol_version = mnl_attr_get_u32(attr);<br>
+               break;<br>
        default:<br>
                warn_unrecognized(&quot;netlink&quot;);<br>
        }<br>
diff --git a/contrib/examples/embeddable-wg-library/wireguard.h<br>
b/contrib/examples/embeddable-wg-library/wireguard.h<br>
index e9210a4..2cee9ac 100644<br>
--- a/contrib/examples/embeddable-wg-library/wireguard.h<br>
+++ b/contrib/examples/embeddable-wg-library/wireguard.h<br>
@@ -49,6 +49,7 @@ typedef struct wg_peer {<br>
        struct timespec last_handshake_time;<br>
        uint64_t rx_bytes, tx_bytes;<br>
        uint16_t persistent_keepalive_interval;<br>
+       uint32_t protocol_version;<br>
<br>
        struct wg_allowedip *first_allowedip, *last_allowedip;<br>
        struct wg_peer *next_peer;<br>
--<br>
2.19.2<br>
</div></div>

[-- 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