From patchwork Sat Apr 27 21:47:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 240208 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 098EC2C0098 for ; Sun, 28 Apr 2013 07:48:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755600Ab3D0Vr6 (ORCPT ); Sat, 27 Apr 2013 17:47:58 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:50429 "EHLO mail-da0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752373Ab3D0Vr5 (ORCPT ); Sat, 27 Apr 2013 17:47:57 -0400 Received: by mail-da0-f45.google.com with SMTP id v40so437568dad.4 for ; Sat, 27 Apr 2013 14:47:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=v5FuiaCLyYDZK8zIkvsQ44Zd1j+pTpgZIj4V6IOJrac=; b=lQTHpmeMJ3Ncbe1A+rXu7bfjAX961HJdxSBS3aBG6t7GDlt7cDgY+2Y4ZNK8EXCJf9 9JjAqSkqUiX+TjLGRZ5XgPgCc+A+tvxTMc6QBn57GwBdNP399K+pGcHgItHQszit//Do 8lb5ZVMlAacYWTbyQmi+k13UHZbb/Sp0JF+4OlQOmJm0mM7qSqFjOJdoZyCBWpN5+n4w 0GRK7I0Iy7KhA7+92GCNJ/ixsG8E0SBtkL0cPXUgTRGbYsUwBaijgNSXv2ZOO7QAxy5y U4vYPaZcFTtxbJlU+fdDwasdXE4ODNvfXuYc2QKNw54Bx/fyowYDia6G0vql/N9CR/br i+ww== X-Received: by 10.68.234.100 with SMTP id ud4mr2041747pbc.9.1367099276363; Sat, 27 Apr 2013 14:47:56 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-71-109.bvtn.or.frontiernet.net. [50.53.71.109]) by mx.google.com with ESMTPSA id qh4sm18680581pac.8.2013.04.27.14.47.55 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 27 Apr 2013 14:47:55 -0700 (PDT) Date: Sat, 27 Apr 2013 14:47:47 -0700 From: Stephen Hemminger To: Stephen Hemminger Cc: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH iproute2] iproute2: add vxlan dstport option Message-ID: <20130427144747.48ace4fb@nehalam.linuxnetplumber.net> In-Reply-To: <20130427213258.534077786@vyatta.com> References: <20130427213151.255971631@vyatta.com> <20130427213258.534077786@vyatta.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Gm-Message-State: ALoCoQnqp3O2O5Pkk42BzrTrmc1eOsHV2HuTFGgGDAznuJVfxgGMKoCIOgPo8tl5QFnRY+uBLqIa Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add ability to set UDP destination port on a per device basis. If no port is assigned, the default IANA assigned port will be used. If you want the kernel default value, then use port 0. Source port range option is now called 'srcport', to avoid confusion. The old option syntax is accepted for compatiablity. Signed-off-by: Stephen Hemminger --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/if_link.h b/include/linux/if_link.h index 40167af..e708e86 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -301,11 +301,12 @@ enum { IFLA_VXLAN_LEARNING, IFLA_VXLAN_AGEING, IFLA_VXLAN_LIMIT, - IFLA_VXLAN_PORT_RANGE, + IFLA_VXLAN_PORT_RANGE, /* source port */ IFLA_VXLAN_PROXY, IFLA_VXLAN_RSC, IFLA_VXLAN_L2MISS, IFLA_VXLAN_L3MISS, + IFLA_VXLAN_PORT, /* destination port */ __IFLA_VXLAN_MAX }; #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c index 1025326..2d93ee2 100644 --- a/ip/iplink_vxlan.c +++ b/ip/iplink_vxlan.c @@ -25,8 +25,8 @@ static void explain(void) { fprintf(stderr, "Usage: ... vxlan id VNI [ group ADDR ] [ local ADDR ]\n"); fprintf(stderr, " [ ttl TTL ] [ tos TOS ] [ dev PHYS_DEV ]\n"); - fprintf(stderr, " [ port MIN MAX ] [ [no]learning ]\n"); - fprintf(stderr, " [ [no]proxy ] [ [no]rsc ]\n"); + fprintf(stderr, " [ dstport PORT ] [ srcport MIN MAX ]\n"); + fprintf(stderr, " [ [no]learning ] [ [no]proxy ] [ [no]rsc ]\n"); fprintf(stderr, " [ [no]l2miss ] [ [no]l3miss ]\n"); fprintf(stderr, "\n"); fprintf(stderr, "Where: VNI := 0-16777215\n"); @@ -53,6 +53,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, __u8 noage = 0; __u32 age = 0; __u32 maxaddr = 0; + __u16 dstport = 4789; struct ifla_vxlan_port_range range = { 0, 0 }; while (argc > 0) { @@ -115,7 +116,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, maxaddr = 0; else if (get_u32(&maxaddr, *argv, 0)) invarg("max addresses", *argv); - } else if (!matches(*argv, "port")) { + } else if (!matches(*argv, "port") || + !matches(*argv, "srcport")) { __u16 minport, maxport; NEXT_ARG(); if (get_u16(&minport, *argv, 0)) @@ -125,6 +127,10 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, invarg("max port", *argv); range.low = htons(minport); range.high = htons(maxport); + } else if (!matches(*argv, "dstport")){ + NEXT_ARG(); + if (get_u16(&dstport, *argv, 0)) + invarg("dst port", *argv); } else if (!matches(*argv, "nolearning")) { learning = 0; } else if (!matches(*argv, "learning")) { @@ -155,7 +161,6 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, } argc--, argv++; } - if (!vni_set) { fprintf(stderr, "vxlan: missing virtual network identifier\n"); return -1; @@ -183,6 +188,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, if (range.low || range.high) addattr_l(n, 1024, IFLA_VXLAN_PORT_RANGE, &range, sizeof(range)); + if (dstport) + addattr16(n, 1024, IFLA_VXLAN_PORT, htons(dstport)); return 0; } @@ -233,9 +240,13 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) if (tb[IFLA_VXLAN_PORT_RANGE]) { const struct ifla_vxlan_port_range *r = RTA_DATA(tb[IFLA_VXLAN_PORT_RANGE]); - fprintf(f, "port %u %u ", ntohs(r->low), ntohs(r->high)); + fprintf(f, "srcport %u %u ", ntohs(r->low), ntohs(r->high)); } + if (tb[IFLA_VXLAN_PORT]) + fprintf(f, "dstport %u ", + ntohs(rta_getattr_u16(tb[IFLA_VXLAN_PORT]))); + if (tb[IFLA_VXLAN_LEARNING] && !rta_getattr_u8(tb[IFLA_VXLAN_LEARNING])) fputs("nolearning ", f);