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] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 17 Nov 2014 06:57:49 +0000
From:	Sathya Perla <Sathya.Perla@...lex.Com>
To:	Mahesh Bandewar <maheshb@...gle.com>,
	netdev <netdev@...r.kernel.org>,
	Stephen Hemminger <stephen@...workplumber.org>
CC:	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

> -----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.

> +}
> +
> +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;
> +}
> +

Powered by blists - more mailing lists