* [uml-devel] [PATCH] tunctl: Allow non-persitent interfaces
@ 2011-03-27 10:28 Alexey Zaytsev
2011-03-27 15:20 ` richard -rw- weinberger
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Zaytsev @ 2011-03-27 10:28 UTC (permalink / raw)
To: user-mode-linux-devel; +Cc: Jeff Dike
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
---
Hello, uml people. Does someone still maintain the uml utilities? You've been
a bit quiet for the last 4 years, but now I've got a patch for you to apply. It's
handy when you run qemu (or anything else that wants persistent tunnels)
inside openvz containers:
http://wiki.openvz.org/VPN_via_the_TUN/TAP_device#The_tunctl_problem
tunctl/tunctl.c | 39 +++++++++++++++++++++++++++++++--------
1 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/tunctl/tunctl.c b/tunctl/tunctl.c
index 16e24a2..0eca752 100644
--- a/tunctl/tunctl.c
+++ b/tunctl/tunctl.c
@@ -21,13 +21,16 @@
static void Usage(char *name)
{
- fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] "
+ fprintf(stderr, "Create: %s [-b] [-n [-m]] [-u owner] [-g group] [-t device-name] "
"[-f tun-clone-device]\n", name);
fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n",
name);
fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems"
" use\n/dev/misc/net/tun instead\n\n");
- fprintf(stderr, "-b will result in brief output (just the device name)\n");
+ fprintf(stderr, "\t-b will result in brief output (just the device name)\n");
+ fprintf(stderr, "\t-n will create a non-persistent tunnel, and sleep until killed\n");
+ fprintf(stderr, "\t-m will daemonize before slleeping, only makes sense with -n\n");
+
exit(1);
}
@@ -38,10 +41,10 @@ int main(int argc, char **argv)
struct group *gr;
uid_t owner = -1;
gid_t group = -1;
- int tap_fd, opt, delete = 0, brief = 0;
+ int tap_fd, opt, delete = 0, brief = 0, persistent = 1, daemonize = 0;
char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end;
- while((opt = getopt(argc, argv, "bd:f:t:u:g:")) > 0){
+ while((opt = getopt(argc, argv, "bd:f:t:u:g:nm")) > 0){
switch(opt) {
case 'b':
brief = 1;
@@ -83,6 +86,13 @@ int main(int argc, char **argv)
case 't':
tun = optarg;
break;
+ case 'n':
+ persistent = 0;
+ break;
+ case 'm':
+ daemonize = 1;
+ break;
+
case 'h':
default:
Usage(name);
@@ -136,21 +146,34 @@ int main(int argc, char **argv)
}
}
- if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){
- perror("enabling TUNSETPERSIST");
- exit(1);
+ if (persistent) {
+ if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){
+ perror("enabling TUNSETPERSIST");
+ exit(1);
+ }
}
if(brief)
printf("%s\n", ifr.ifr_name);
else {
- printf("Set '%s' persistent and owned by", ifr.ifr_name);
+ if (persistent) {
+ printf("Set '%s' persistent and owned by", ifr.ifr_name);
+ } else {
+ printf("(%u) Sleeping on non-persistent '%s' owned by",
+ getpid(), ifr.ifr_name);
+ }
if(owner != -1)
printf(" uid %d", owner);
if(group != -1)
printf(" gid %d", group);
printf("\n");
}
+
+ if (!persistent) {
+ if (daemonize)
+ daemon(1, 1);
+ pause();
+ }
}
return(0);
}
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [uml-devel] [PATCH] tunctl: Allow non-persitent interfaces
2011-03-27 10:28 [uml-devel] [PATCH] tunctl: Allow non-persitent interfaces Alexey Zaytsev
@ 2011-03-27 15:20 ` richard -rw- weinberger
2011-05-03 17:01 ` Rob Landley
0 siblings, 1 reply; 3+ messages in thread
From: richard -rw- weinberger @ 2011-03-27 15:20 UTC (permalink / raw)
To: Alexey Zaytsev; +Cc: Jeff Dike, user-mode-linux-devel
On Sun, Mar 27, 2011 at 12:28 PM, Alexey Zaytsev
<alexey.zaytsev@gmail.com> wrote:
> Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
> ---
Alexey,
> Hello, uml people. Does someone still maintain the uml utilities? You've been
> a bit quiet for the last 4 years, but now I've got a patch for you to apply. It's
> handy when you run qemu (or anything else that wants persistent tunnels)
> inside openvz containers:
> http://wiki.openvz.org/VPN_via_the_TUN/TAP_device#The_tunctl_problem
>
Thanks for the patch.
Currently nobody seems to maintain the uml utilities.
I'm doing some work on UML.
Until now no work on uml utilities was needed.
I'll take care of it.
> tunctl/tunctl.c | 39 +++++++++++++++++++++++++++++++--------
> 1 files changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/tunctl/tunctl.c b/tunctl/tunctl.c
> index 16e24a2..0eca752 100644
> --- a/tunctl/tunctl.c
> +++ b/tunctl/tunctl.c
> @@ -21,13 +21,16 @@
>
> static void Usage(char *name)
> {
> - fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] "
> + fprintf(stderr, "Create: %s [-b] [-n [-m]] [-u owner] [-g group] [-t device-name] "
> "[-f tun-clone-device]\n", name);
> fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n",
> name);
> fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems"
> " use\n/dev/misc/net/tun instead\n\n");
> - fprintf(stderr, "-b will result in brief output (just the device name)\n");
> + fprintf(stderr, "\t-b will result in brief output (just the device name)\n");
> + fprintf(stderr, "\t-n will create a non-persistent tunnel, and sleep until killed\n");
> + fprintf(stderr, "\t-m will daemonize before slleeping, only makes sense with -n\n");
> +
> exit(1);
> }
>
> @@ -38,10 +41,10 @@ int main(int argc, char **argv)
> struct group *gr;
> uid_t owner = -1;
> gid_t group = -1;
> - int tap_fd, opt, delete = 0, brief = 0;
> + int tap_fd, opt, delete = 0, brief = 0, persistent = 1, daemonize = 0;
> char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end;
>
> - while((opt = getopt(argc, argv, "bd:f:t:u:g:")) > 0){
> + while((opt = getopt(argc, argv, "bd:f:t:u:g:nm")) > 0){
> switch(opt) {
> case 'b':
> brief = 1;
> @@ -83,6 +86,13 @@ int main(int argc, char **argv)
> case 't':
> tun = optarg;
> break;
> + case 'n':
> + persistent = 0;
> + break;
> + case 'm':
> + daemonize = 1;
> + break;
> +
> case 'h':
> default:
> Usage(name);
> @@ -136,21 +146,34 @@ int main(int argc, char **argv)
> }
> }
>
> - if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){
> - perror("enabling TUNSETPERSIST");
> - exit(1);
> + if (persistent) {
> + if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){
> + perror("enabling TUNSETPERSIST");
> + exit(1);
> + }
> }
>
> if(brief)
> printf("%s\n", ifr.ifr_name);
> else {
> - printf("Set '%s' persistent and owned by", ifr.ifr_name);
> + if (persistent) {
> + printf("Set '%s' persistent and owned by", ifr.ifr_name);
> + } else {
> + printf("(%u) Sleeping on non-persistent '%s' owned by",
> + getpid(), ifr.ifr_name);
> + }
> if(owner != -1)
> printf(" uid %d", owner);
> if(group != -1)
> printf(" gid %d", group);
> printf("\n");
> }
> +
> + if (!persistent) {
> + if (daemonize)
> + daemon(1, 1);
> + pause();
> + }
> }
> return(0);
> }
>
>
> ------------------------------------------------------------------------------
> Enable your software for Intel(R) Active Management Technology to meet the
> growing manageability and security demands of your customers. Businesses
> are taking advantage of Intel(R) vPro (TM) technology - will your software
> be a part of the solution? Download the Intel(R) Manageability Checker
> today! http://p.sf.net/sfu/intel-dev2devmar
> _______________________________________________
> User-mode-linux-devel mailing list
> User-mode-linux-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
>
--
Thanks,
//richard
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [uml-devel] [PATCH] tunctl: Allow non-persitent interfaces
2011-03-27 15:20 ` richard -rw- weinberger
@ 2011-05-03 17:01 ` Rob Landley
0 siblings, 0 replies; 3+ messages in thread
From: Rob Landley @ 2011-05-03 17:01 UTC (permalink / raw)
To: user-mode-linux-devel
On 03/27/2011 10:20 AM, richard -rw- weinberger wrote:
> On Sun, Mar 27, 2011 at 12:28 PM, Alexey Zaytsev
> <alexey.zaytsev@gmail.com> wrote:
>> Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
>> ---
>
> Alexey,
>
>> Hello, uml people. Does someone still maintain the uml utilities? You've been
>> a bit quiet for the last 4 years, but now I've got a patch for you to apply. It's
>> handy when you run qemu (or anything else that wants persistent tunnels)
>> inside openvz containers:
>> http://wiki.openvz.org/VPN_via_the_TUN/TAP_device#The_tunctl_problem
...
>> + fprintf(stderr, "\t-m will daemonize before slleeping, only makes sense with -n\n");
>> +
Typo, "slleeping".
Rob
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-03 17:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-27 10:28 [uml-devel] [PATCH] tunctl: Allow non-persitent interfaces Alexey Zaytsev
2011-03-27 15:20 ` richard -rw- weinberger
2011-05-03 17:01 ` Rob Landley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.