From patchwork Sat Aug 12 12:04:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 800902 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xV10J11qNz9t3C for ; Sat, 12 Aug 2017 22:10:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752667AbdHLMKG (ORCPT ); Sat, 12 Aug 2017 08:10:06 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:44375 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbdHLMKF (ORCPT ); Sat, 12 Aug 2017 08:10:05 -0400 Received: from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1]) by mail.nwl.cc (Postfix) with ESMTP id 94F0F683D9; Sat, 12 Aug 2017 14:10:04 +0200 (CEST) Received: from xsao (localhost [IPv6:::1]) by mail.nwl.cc (Postfix) with ESMTP id 786AA681D7; Sat, 12 Aug 2017 14:10:04 +0200 (CEST) From: Phil Sutter To: Stephen Hemminger Cc: netdev@vger.kernel.org Subject: [iproute PATCH 12/51] iproute_lwtunnel: csum_mode value checking was ineffective Date: Sat, 12 Aug 2017 14:04:31 +0200 Message-Id: <20170812120510.28750-13-phil@nwl.cc> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170812120510.28750-1-phil@nwl.cc> References: <20170812120510.28750-1-phil@nwl.cc> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ila_csum_name2mode() returning -1 on error but being declared as returning __u8 doesn't make much sense. Change the code to correctly detect this issue. Checking for __u8 overruns shouldn't be necessary though since ila_csum_name2mode() return values are well-defined. Signed-off-by: Phil Sutter --- ip/iproute_lwtunnel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c index 5c0c7d110d23e..398ab5e077ed8 100644 --- a/ip/iproute_lwtunnel.c +++ b/ip/iproute_lwtunnel.c @@ -171,7 +171,7 @@ static char *ila_csum_mode2name(__u8 csum_mode) } } -static __u8 ila_csum_name2mode(char *name) +static int ila_csum_name2mode(char *name) { if (strcmp(name, "adj-transport") == 0) return ILA_CSUM_ADJUST_TRANSPORT; @@ -517,7 +517,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len, while (argc > 0) { if (strcmp(*argv, "csum-mode") == 0) { - __u8 csum_mode; + int csum_mode; NEXT_ARG(); @@ -526,7 +526,8 @@ static int parse_encap_ila(struct rtattr *rta, size_t len, invarg("\"csum-mode\" value is invalid\n", *argv); - rta_addattr8(rta, 1024, ILA_ATTR_CSUM_MODE, csum_mode); + rta_addattr8(rta, 1024, ILA_ATTR_CSUM_MODE, + (__u8)csum_mode); argc--; argv++; } else {