From patchwork Wed Mar 26 16:33:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 333996 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 892D7140090 for ; Thu, 27 Mar 2014 03:33:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755801AbaCZQdO (ORCPT ); Wed, 26 Mar 2014 12:33:14 -0400 Received: from mail-ee0-f44.google.com ([74.125.83.44]:39943 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754076AbaCZQdM (ORCPT ); Wed, 26 Mar 2014 12:33:12 -0400 Received: by mail-ee0-f44.google.com with SMTP id e49so1855971eek.17 for ; Wed, 26 Mar 2014 09:33:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jucOl6xeXl5vqnjzHEXj564LljxC6RJbbLt3+IGpxy4=; b=GEhrcnXqD/8r50ZFh5UOi6QG8IqzJAVJgjr3wa4uCmP1fK0eOi5O6ue7z86gwsSYMe fiQnR7jPTSQzUcG8ir2W+q8ncqVnYed6IVHR39o7hfsOHOJxyiEi6KW9E2ZDI644rwBm jKBDCapZIalyOPOvJeJGIS3rTFMoaxIOIgRhmWwRmnYYOLhlBaGjUBHSuen/JRgLGcwU 72UVzMD/iIUjjaP3EvZYpAG+O6uvggcbTquzFErfOwo58j5ICFTkoylauVS39VYMafaK ghDxDB+Qv/FHYQFFVN/PDexNjAE0F+y5yon8w//olhNgICwrNACBg2no93a+6ngwZ0aa 6Z8g== X-Gm-Message-State: ALoCoQn7wXY/eU58mM6x3EC+WLjcMT9FJq9UMl88RgXO/biref6eEYOhIYHNmWn+U/RdXoiZmmok X-Received: by 10.14.251.204 with SMTP id b52mr53605317ees.36.1395851591920; Wed, 26 Mar 2014 09:33:11 -0700 (PDT) Received: from localhost (ip-94-113-121-85.net.upcbroadband.cz. [94.113.121.85]) by mx.google.com with ESMTPSA id m8sm48126365eeg.11.2014.03.26.09.33.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 09:33:11 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Subject: [patch iproute2 RFC v2] iproute: add support for dummyswport Date: Wed, 26 Mar 2014 17:33:10 +0100 Message-Id: <1395851590-10586-1-git-send-email-jiri@resnulli.us> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395851472-10524-1-git-send-email-jiri@resnulli.us> References: <1395851472-10524-1-git-send-email-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Jiri Pirko --- include/linux/if_link.h | 9 +++++++++ ip/Makefile | 3 ++- ip/iplink_dummyswport.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 ip/iplink_dummyswport.c diff --git a/include/linux/if_link.h b/include/linux/if_link.h index f08505c..aa3d619 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -542,4 +542,13 @@ enum { #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1) +/* DUMMYSWPORT section */ +enum { + IFLA_DUMMYSWPORT_UNSPEC, + IFLA_DUMMYSWPORT_MASTER, + __IFLA_DUMMYSWPORT_MAX, +}; + +#define IFLA_DUMMYSWPORT_MAX (__IFLA_DUMMYSWPORT_MAX - 1) + #endif /* _LINUX_IF_LINK_H */ diff --git a/ip/Makefile b/ip/Makefile index 713adf5..35546e5 100644 --- a/ip/Makefile +++ b/ip/Makefile @@ -5,7 +5,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ iplink_vlan.o link_veth.o link_gre.o iplink_can.o \ iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \ iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \ - link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o + link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \ + iplink_dummyswport.o \ RTMONOBJ=rtmon.o diff --git a/ip/iplink_dummyswport.c b/ip/iplink_dummyswport.c new file mode 100644 index 0000000..a6476d1 --- /dev/null +++ b/ip/iplink_dummyswport.c @@ -0,0 +1,54 @@ +/* + * iplink_dummyswport.c dummy switch port device support + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Jiri Pirko + */ + +#include +#include +#include +#include +#include +#include + +#include "rt_names.h" +#include "utils.h" +#include "ip_common.h" + +static void explain(void) +{ + fprintf(stderr, "Usage: ... dummyswport master DUMMYSW_DEV\n"); +} + +static int dummyswport_parse_opt(struct link_util *lu, int argc, char **argv, + struct nlmsghdr *n) +{ + while (argc > 0) { + if (matches(*argv, "master") == 0) { + unsigned ifindex; + + NEXT_ARG(); + ifindex = if_nametoindex(*argv); + if (!ifindex) + invarg("Device does not exist\n", *argv); + addattr32(n, 1024, IFLA_DUMMYSWPORT_MASTER, ifindex); + } else { + fprintf(stderr, "dummyswport: unknown option \"%s\"?\n", *argv); + explain(); + return -1; + } + argc--, argv++; + } + return 0; +} + +struct link_util dummyswport_link_util = { + .id = "dummyswport", + .maxattr = IFLA_DUMMYSWPORT_MAX, + .parse_opt = dummyswport_parse_opt, +};