From patchwork Thu Nov 8 11:21:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Brivio X-Patchwork-Id: 994794 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42rLTK0Q2jz9s47 for ; Thu, 8 Nov 2018 22:21:41 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727299AbeKHU4k (ORCPT ); Thu, 8 Nov 2018 15:56:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52614 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726145AbeKHU4k (ORCPT ); Thu, 8 Nov 2018 15:56:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7009158E5C; Thu, 8 Nov 2018 11:21:39 +0000 (UTC) Received: from epycfail.redhat.com (ovpn-200-16.brq.redhat.com [10.40.200.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DC565C26A; Thu, 8 Nov 2018 11:21:37 +0000 (UTC) From: Stefano Brivio To: David Ahern Cc: Stephen Hemminger , netdev@vger.kernel.org Subject: [PATCH iproute2 net-next v2 2/2] iplink_geneve: Add DF configuration Date: Thu, 8 Nov 2018 12:21:26 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Nov 2018 11:21:39 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allow to set the DF bit behaviour for outgoing IPv4 packets: it can be always on, inherited from the inner header, or, by default, always off, which is the current behaviour. v2: - Indicate in the man page what DF refers to, using RFC 791 wording (David Ahern) Signed-off-by: Stefano Brivio --- include/uapi/linux/if_link.h | 9 +++++++++ ip/iplink_geneve.c | 29 +++++++++++++++++++++++++++++ man/man8/ip-link.8.in | 14 ++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 4caf683ce546..183ca7527178 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -563,10 +563,19 @@ enum { IFLA_GENEVE_UDP_ZERO_CSUM6_RX, IFLA_GENEVE_LABEL, IFLA_GENEVE_TTL_INHERIT, + IFLA_GENEVE_DF, __IFLA_GENEVE_MAX }; #define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1) +enum ifla_geneve_df { + GENEVE_DF_UNSET = 0, + GENEVE_DF_SET, + GENEVE_DF_INHERIT, + __GENEVE_DF_END, + GENEVE_DF_MAX = __GENEVE_DF_END - 1, +}; + /* PPP section */ enum { IFLA_PPP_UNSPEC, diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c index c417842b2a5b..1872b74c5d70 100644 --- a/ip/iplink_geneve.c +++ b/ip/iplink_geneve.c @@ -24,6 +24,7 @@ static void print_explain(FILE *f) " remote ADDR\n" " [ ttl TTL ]\n" " [ tos TOS ]\n" + " [ df DF ]\n" " [ flowlabel LABEL ]\n" " [ dstport PORT ]\n" " [ [no]external ]\n" @@ -35,6 +36,7 @@ static void print_explain(FILE *f) " ADDR := IP_ADDRESS\n" " TOS := { NUMBER | inherit }\n" " TTL := { 1..255 | auto | inherit }\n" + " DF := { unset | set | inherit }\n" " LABEL := 0-1048575\n" ); } @@ -115,6 +117,22 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv, tos = uval; } else tos = 1; + } else if (!matches(*argv, "df")) { + enum ifla_geneve_df df; + + NEXT_ARG(); + check_duparg(&attrs, IFLA_GENEVE_DF, "df", *argv); + if (strcmp(*argv, "unset") == 0) + df = GENEVE_DF_UNSET; + else if (strcmp(*argv, "set") == 0) + df = GENEVE_DF_SET; + else if (strcmp(*argv, "inherit") == 0) + df = GENEVE_DF_INHERIT; + else + invarg("DF must be 'unset', 'set' or 'inherit'", + *argv); + + addattr8(n, 1024, IFLA_GENEVE_DF, df); } else if (!matches(*argv, "label") || !matches(*argv, "flowlabel")) { __u32 uval; @@ -287,6 +305,17 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) print_string(PRINT_FP, NULL, "tos %s ", "inherit"); } + if (tb[IFLA_GENEVE_DF]) { + enum ifla_geneve_df df = rta_getattr_u8(tb[IFLA_GENEVE_DF]); + + if (df == GENEVE_DF_UNSET) + print_string(PRINT_JSON, "df", "df %s ", "unset"); + else if (df == GENEVE_DF_SET) + print_string(PRINT_ANY, "df", "df %s ", "set"); + else if (df == GENEVE_DF_INHERIT) + print_string(PRINT_ANY, "df", "df %s ", "inherit"); + } + if (tb[IFLA_GENEVE_LABEL]) { __u32 label = rta_getattr_u32(tb[IFLA_GENEVE_LABEL]); diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index a94cf4f19f1e..73d37c190fff 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -1180,6 +1180,8 @@ the following additional arguments are supported: ] [ .BI tos " TOS " ] [ +.BI df " DF " +] [ .BI flowlabel " FLOWLABEL " ] [ .BI dstport " PORT" @@ -1212,6 +1214,18 @@ ttl. Default option is "0". .BI tos " TOS" - specifies the TOS value to use in outgoing packets. +.sp +.BI df " DF" +- specifies the usage of the Don't Fragment flag (DF) bit in outgoing packets +with IPv4 headers. The value +.B inherit +causes the bit to be copied from the original IP header. The values +.B unset +and +.B set +cause the bit to be always unset or always set, respectively. By default, the +bit is not set. + .sp .BI flowlabel " FLOWLABEL" - specifies the flow label to use in outgoing packets.