Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F101851085
D37606.id114128.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D37606.id114128.diff
View Options
diff --git a/sys/net/if_ovpn.c b/sys/net/if_ovpn.c
--- a/sys/net/if_ovpn.c
+++ b/sys/net/if_ovpn.c
@@ -114,14 +114,6 @@
uint8_t auth_tag[16];
};
-struct ovpn_notification {
- enum ovpn_notif_type type;
- enum ovpn_del_reason del_reason;
- uint32_t peerid;
-};
-
-struct ovpn_softc;
-
struct ovpn_peer_counters {
uint64_t pkt_in;
uint64_t pkt_out;
@@ -130,6 +122,17 @@
};
#define OVPN_PEER_COUNTER_SIZE (sizeof(struct ovpn_peer_counters)/sizeof(uint64_t))
+struct ovpn_notification {
+ enum ovpn_notif_type type;
+ uint32_t peerid;
+
+ /* Delete notification */
+ enum ovpn_del_reason del_reason;
+ struct ovpn_peer_counters counters;
+};
+
+struct ovpn_softc;
+
struct ovpn_kpeer {
RB_ENTRY(ovpn_kpeer) tree;
int refcount;
@@ -438,6 +441,16 @@
n->peerid = peer->peerid;
n->type = OVPN_NOTIF_DEL_PEER;
n->del_reason = peer->del_reason;
+
+ n->counters.pkt_in = counter_u64_fetch(peer->counters[offsetof(
+ struct ovpn_peer_counters, pkt_in)/sizeof(uint64_t)]);
+ n->counters.pkt_out = counter_u64_fetch(peer->counters[offsetof(
+ struct ovpn_peer_counters, pkt_out)/sizeof(uint64_t)]);
+ n->counters.bytes_in = counter_u64_fetch(peer->counters[offsetof(
+ struct ovpn_peer_counters, bytes_in)/sizeof(uint64_t)]);
+ n->counters.bytes_out = counter_u64_fetch(peer->counters[offsetof(
+ struct ovpn_peer_counters, bytes_out)/sizeof(uint64_t)]);
+
if (buf_ring_enqueue(sc->notifring, n) != 0) {
free(n, M_OVPN);
} else if (sc->so != NULL) {
@@ -1335,6 +1348,32 @@
return (0);
}
+static void
+ovpn_notif_add_counters(nvlist_t *parent, struct ovpn_notification *n)
+{
+ nvlist_t *nvl;
+
+ nvl = nvlist_create(0);
+ if (nvl == NULL)
+ return;
+
+ nvlist_add_number(nvl, "in", n->counters.pkt_in);
+ nvlist_add_number(nvl, "out", n->counters.pkt_out);
+
+ nvlist_add_nvlist(parent, "packets", nvl);
+ nvlist_destroy(nvl);
+
+ nvl = nvlist_create(0);
+ if (nvl == NULL)
+ return;
+
+ nvlist_add_number(nvl, "in", n->counters.bytes_in);
+ nvlist_add_number(nvl, "out", n->counters.bytes_out);
+
+ nvlist_add_nvlist(parent, "bytes", nvl);
+ nvlist_destroy(nvl);
+}
+
static int
opvn_get_pkt(struct ovpn_softc *sc, nvlist_t **onvl)
{
@@ -1353,8 +1392,13 @@
}
nvlist_add_number(nvl, "peerid", n->peerid);
nvlist_add_number(nvl, "notification", n->type);
- if (n->type == OVPN_NOTIF_DEL_PEER)
+ if (n->type == OVPN_NOTIF_DEL_PEER) {
nvlist_add_number(nvl, "del_reason", n->del_reason);
+
+ /* No error handling, because we want to send the notification
+ * even if we can't attach the counters. */
+ ovpn_notif_add_counters(nvl, n);
+ }
free(n, M_OVPN);
*onvl = nvl;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 4:46 PM (13 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14470176
Default Alt Text
D37606.id114128.diff (2 KB)
Attached To
Mode
D37606: if_ovpn: include peer counters in a OVPN_NOTIF_DEL_PEER message
Attached
Detach File
Event Timeline
Log In to Comment