]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
ipl2tp: allow setting session interface name
authorJoão Valverde <jpv950@gmail.com>
Mon, 26 Mar 2012 20:00:08 +0000 (21:00 +0100)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Tue, 3 Apr 2012 18:38:51 +0000 (11:38 -0700)
Hi,

I've attached a trivial patch for iproute2 to allow naming interfaces
created with "ip l2tp add session".

I believe patches should go through the netdev mailing list but this
patch is so small I figured that would just add noise. Hope that's OK.

Originally I thought I would need a bigger patch and was going to take a
stab at implementing something like

ip l2tp add tunnel L2TP_TUNNEL_ARGS
ip link add name NAME  [ LINK_OPTS ] type l2tp L2TP_SESSION_ARGS

(a better interface IMHO) but all the code was there already, all that I
needed to add was option parsing.

Thanks,

João Valverde

From fd8c3b712527d2e959aeabc6f6b71a9910e7be7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= <joao.valverde@ist.utl.pt>
Date: Mon, 26 Mar 2012 18:30:56 +0100
Subject: [PATCH] ipl2tp: allow setting session interface name

ip/ipl2tp.c

index 97f98b68b08bf6e0a9035468992e03ef868178b2..c5683f567568fd2d131826231aeadfe573291f25 100644 (file)
@@ -488,7 +488,7 @@ static void usage(void)
        fprintf(stderr, "          tunnel_id ID peer_tunnel_id ID\n");
        fprintf(stderr, "          [ encap { ip | udp } ]\n");
        fprintf(stderr, "          [ udp_sport PORT ] [ udp_dport PORT ]\n");
-       fprintf(stderr, "Usage: ip l2tp add session\n");
+       fprintf(stderr, "Usage: ip l2tp add session [ name NAME ]\n");
        fprintf(stderr, "          tunnel_id ID\n");
        fprintf(stderr, "          session_id ID peer_session_id ID\n");
        fprintf(stderr, "          [ cookie HEXSTR ] [ peer_cookie HEXSTR ]\n");
@@ -524,6 +524,9 @@ static int parse_args(int argc, char **argv, int cmd, struct l2tp_parm *p)
                                fprintf(stderr, "Unknown tunnel encapsulation.\n");
                                exit(-1);
                        }
+               } else if (strcmp(*argv, "name") == 0) {
+                       NEXT_ARG();
+                       p->ifname = *argv;
                } else if (strcmp(*argv, "remote") == 0) {
                        NEXT_ARG();
                        p->peer_ip.s_addr = get_addr32(*argv);