lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 17 Nov 2014 13:54:43 -0800
From:	Mahesh Bandewar <maheshb@...gle.com>
To:	Sathya Perla <Sathya.Perla@...lex.com>
Cc:	netdev <netdev@...r.kernel.org>,
	Stephen Hemminger <stephen@...workplumber.org>,
	Eric Dumazet <edumazet@...gle.com>,
	Maciej Zenczykowski <maze@...gle.com>,
	Laurent Chavey <chavey@...gle.com>,
	Tim Hockin <thockin@...gle.com>,
	David Miller <davem@...emloft.net>,
	Brandon Philips <brandon.philips@...eos.com>,
	Pavel Emelianov <xemul@...allels.com>
Subject: Re: [PATCH Iproute2 next v1] ip link: Add ipvlan support to the
 iproute2/ip util

On Sun, Nov 16, 2014 at 10:57 PM, Sathya Perla <Sathya.Perla@...lex.com> wrote:
>
> > -----Original Message-----
> > From: netdev-owner@...r.kernel.org [mailto:netdev-
> >
> > Adding basic support to create virtual devices using 'ip'
> > utility. Following is the syntax -
> >
> >       ip link add link <master> <virtual> type ipvlan mode [ l2 | l3 ]
> >       e.g. ip link add link eth0 ipvl0 type ipvlan mode l3
> >
> ..
> > ---
> >  include/linux/if_link.h | 14 ++++++++
> >  ip/Makefile             |  2 +-
> >  ip/iplink.c             |  2 +-
> >  ip/iplink_ipvlan.c      | 85
> > +++++++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 101 insertions(+), 2 deletions(-)
> >  create mode 100644 ip/iplink_ipvlan.c
> >
> > diff --git a/include/linux/if_link.h b/include/linux/if_link.h
> > index 47320636361c..ef1e9f73fb15 100644
> > --- a/include/linux/if_link.h
> > +++ b/include/linux/if_link.h
> > @@ -325,6 +325,20 @@ enum macvlan_macaddr_mode {
> >       MACVLAN_MACADDR_SET,
> >  };
> >
> > +/* IPVLAN section */
> > +enum {
> > +     IFLA_IPVLAN_UNSPEC,
> > +     IFLA_IPVLAN_MODE,
> > +     __IFLA_IPVLAN_MAX,
> > +};
> > +
> > +#define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
> > +
> > +enum ipvlan_mode {
> > +     IPVLAN_MODE_L2 = 0, /* Process packets all the way upto L2 */
> > +     IPVLAN_MODE_L3 = 1, /* Process Packets all the way upto L3 */
> > +};
> > +
> >  #define MACVLAN_FLAG_NOPROMISC       1
> >
> >... +
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <sys/socket.h>
> > +#include <linux/if_link.h>
> > +
> > +#include "rt_names.h"
> > +#include "utils.h"
> > +#include "ip_common.h"
> > +
> > +static void explain(void)
> > +{
> > +     fprintf(stderr, "Usage: ... ipvlan [ mode { l2 | l3 } ]\n");
> > +}
> > +
> > +static int mode_arg(void)
> > +{
> > +     fprintf(stderr, "Error: argument of \"mode\" must be either \"l2\", "
> > +             "or \"l3\"\n");
> > +        return -1;
> I guess you wanted to "return -1" from the caller routine ipvlan_parse_opt()
> and not from this routine.
>
Hmmm, that caught another error where I intended it to be "return
mode_arg()" instead of just "mode_arg" in the caller. This is clearly
wrong! Thanks for catching it.
> > +}
> > +
> > +static int ipvlan_parse_opt(struct link_util *lu, int argc, char **argv,
> > +                       struct nlmsghdr *n)
> > +{
> > +     while (argc > 0) {
> > +         if (matches(*argv, "mode") == 0) {
> > +                     __u16 mode = 0;
> > +                     NEXT_ARG();
> > +
> > +                     if (strcmp(*argv, "l2") == 0)
> > +                             mode = IPVLAN_MODE_L2;
> > +                     else if (strcmp(*argv, "l3") == 0)
> > +                             mode = IPVLAN_MODE_L3;
> > +                     else
> > +                             mode_arg();
> > +
> > +                     addattr16(n, 1024, IFLA_IPVLAN_MODE, mode);
> > +             } else if (matches(*argv, "help") == 0) {
> > +                     explain();
> > +                     return -1;
> > +             } else {
> > +                     fprintf(stderr, "ipvlan: unknown option \"%s\"?\n",
> > *argv);
> > +                     explain();
> > +                     return -1;
> > +             }
> > +             argc--, argv++;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists