Skip to content

Commit b386d52

Browse files
VitalyVovnoboylguohan
authored andcommitted
Update Tun/Tap by adding enable/disable carrier ability. (sonic-net#22)
1 parent 9a638cb commit b386d52

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 7f7d6a7dd958ff68da96a78442ffa6a404aa976a Mon Sep 17 00:00:00 2001
2+
From: admin <admin@debian>
3+
Date: Tue, 13 Jun 2017 10:49:50 -0400
4+
Subject: [PATCH] TUNTAP driver support carrier configuration
5+
6+
---
7+
drivers/net/tun.c | 12 ++++++++++++
8+
include/uapi/linux/if_tun.h | 1 +
9+
2 files changed, 13 insertions(+)
10+
11+
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
12+
index 999484f..0b1327f 100644
13+
--- a/drivers/net/tun.c
14+
+++ b/drivers/net/tun.c
15+
@@ -2102,6 +2102,18 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
16+
break;
17+
ret = 0;
18+
break;
19+
+
20+
+ case TUNSETCARRIER:
21+
+ if (arg) {
22+
+ netif_carrier_on(tun->dev);
23+
+ } else {
24+
+ netif_carrier_off(tun->dev);
25+
+ }
26+
+
27+
+ tun_debug(KERN_INFO, tun, "carrier %s\n",
28+
+ arg ? "on" : "off");
29+
+
30+
+ break;
31+
32+
default:
33+
ret = -EINVAL;
34+
diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
35+
index e9502dd..319a129 100644
36+
--- a/include/uapi/linux/if_tun.h
37+
+++ b/include/uapi/linux/if_tun.h
38+
@@ -58,6 +58,7 @@
39+
#define TUNSETQUEUE _IOW('T', 217, int)
40+
#define TUNSETIFINDEX _IOW('T', 218, unsigned int)
41+
#define TUNGETFILTER _IOR('T', 219, struct sock_fprog)
42+
+#define TUNSETCARRIER _IOW('T', 220, int)
43+
44+
/* TUNSETIFF ifr flags */
45+
#define IFF_TUN 0x0001
46+
--
47+
2.1.4
48+

patch/series

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ linux-3.19-mmc-sdhci-pci-enable-the-clear-transfer-mode-registe.patch
2626
linux-3.19-mmc-sdhci-pci-enable-sdhci-doesn-t-support-hs200-qui.patch
2727
rtnetlink-catch-EOPNOTSUPP-errors.patch
2828
bridge-per-port-multicast-broadcast-flood-flags.patch
29+
driver-support-tun-config-carrier-enable.patch

0 commit comments

Comments
 (0)