projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sparse fixup: error: too many arguments for function send_key_changed
[tinc]
/
src
/
linux
/
device.c
diff --git
a/src/linux/device.c
b/src/linux/device.c
index
6c828c0
..
111b98c
100644
(file)
--- a/
src/linux/device.c
+++ b/
src/linux/device.c
@@
-47,11
+47,14
@@
char *iface = NULL;
static char ifrname[IFNAMSIZ];
static char *device_info;
static char ifrname[IFNAMSIZ];
static char *device_info;
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
+uint64_t device_in_packets = 0;
+uint64_t device_in_bytes = 0;
+uint64_t device_out_packets = 0;
+uint64_t device_out_bytes = 0;
bool setup_device(void) {
struct ifreq ifr;
bool setup_device(void) {
struct ifreq ifr;
+ bool t1q = false;
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
device = xstrdup(DEFAULT_DEVICE);
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
device = xstrdup(DEFAULT_DEVICE);
@@
-73,7
+76,7
@@
bool setup_device(void) {
#ifdef HAVE_LINUX_IF_TUN_H
/* Ok now check if this is an old ethertap or a new tun/tap thingie */
#ifdef HAVE_LINUX_IF_TUN_H
/* Ok now check if this is an old ethertap or a new tun/tap thingie */
- memset(&ifr, 0, sizeof
(ifr)
);
+ memset(&ifr, 0, sizeof
ifr
);
if(routing_mode == RMODE_ROUTER) {
ifr.ifr_flags = IFF_TUN;
device_type = DEVICE_TYPE_TUN;
if(routing_mode == RMODE_ROUTER) {
ifr.ifr_flags = IFF_TUN;
device_type = DEVICE_TYPE_TUN;
@@
-84,6
+87,12
@@
bool setup_device(void) {
device_info = "Linux tun/tap device (tap mode)";
}
device_info = "Linux tun/tap device (tap mode)";
}
+#ifdef IFF_ONE_QUEUE
+ /* Set IFF_ONE_QUEUE flag... */
+ if(get_config_bool(lookup_config(config_tree, "IffOneQueue"), &t1q) && t1q)
+ ifr.ifr_flags |= IFF_ONE_QUEUE;
+#endif
+
if(iface)
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
if(iface)
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
@@
-121,45
+130,46
@@
void close_device(void) {
}
bool read_packet(vpn_packet_t *packet) {
}
bool read_packet(vpn_packet_t *packet) {
- int
leni
n;
+ int
inle
n;
switch(device_type) {
case DEVICE_TYPE_TUN:
switch(device_type) {
case DEVICE_TYPE_TUN:
-
leni
n = read(device_fd, packet->data + 10, MTU - 10);
+
inle
n = read(device_fd, packet->data + 10, MTU - 10);
- if(
leni
n <= 0) {
+ if(
inle
n <= 0) {
logger(LOG_ERR, "Error while reading from %s %s: %s",
device_info, device, strerror(errno));
return false;
}
logger(LOG_ERR, "Error while reading from %s %s: %s",
device_info, device, strerror(errno));
return false;
}
- packet->len =
leni
n + 10;
+ packet->len =
inle
n + 10;
break;
case DEVICE_TYPE_TAP:
break;
case DEVICE_TYPE_TAP:
-
leni
n = read(device_fd, packet->data, MTU);
+
inle
n = read(device_fd, packet->data, MTU);
- if(
leni
n <= 0) {
+ if(
inle
n <= 0) {
logger(LOG_ERR, "Error while reading from %s %s: %s",
device_info, device, strerror(errno));
return false;
}
logger(LOG_ERR, "Error while reading from %s %s: %s",
device_info, device, strerror(errno));
return false;
}
- packet->len =
leni
n;
+ packet->len =
inle
n;
break;
case DEVICE_TYPE_ETHERTAP:
break;
case DEVICE_TYPE_ETHERTAP:
-
leni
n = read(device_fd, packet->data - 2, MTU + 2);
+
inle
n = read(device_fd, packet->data - 2, MTU + 2);
- if(
leni
n <= 0) {
+ if(
inle
n <= 0) {
logger(LOG_ERR, "Error while reading from %s %s: %s",
device_info, device, strerror(errno));
return false;
}
logger(LOG_ERR, "Error while reading from %s %s: %s",
device_info, device, strerror(errno));
return false;
}
- packet->len =
leni
n - 2;
+ packet->len =
inle
n - 2;
break;
}
break;
}
- device_total_in += packet->len;
+ device_in_packets++;
+ device_in_bytes += packet->len;
ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
device_info);
ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
device_info);
@@
-198,13
+208,14
@@
bool write_packet(vpn_packet_t *packet) {
break;
}
break;
}
- device_total_out += packet->len;
+ device_out_packets++;
+ device_out_bytes += packet->len;
return true;
}
void dump_device_stats(void) {
logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
return true;
}
void dump_device_stats(void) {
logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device);
- logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_
total_in
);
- logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_
total_out
);
+ logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_
in_bytes
);
+ logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_
out_bytes
);
}
}