From: Amir Vadai Date: Sun, 14 May 2017 08:17:44 +0000 (+0300) Subject: pedit: Do not allow using retain for too big fields X-Git-Tag: v4.12.0~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdca191862775c47533908301760edd55763e861;p=thirdparty%2Fiproute2.git pedit: Do not allow using retain for too big fields Using retain for fields longer than 32 bits is not supported. Do not allow user to do it. Signed-off-by: Amir Vadai --- diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8 index 7f482eafc..9c4d57b97 100644 --- a/man/man8/tc-pedit.8 +++ b/man/man8/tc-pedit.8 @@ -266,7 +266,8 @@ Keep the addressed data as is. .BI retain " RVAL" This optional extra part of .I CMD_SPEC -allows to exclude bits from being changed. +allows to exclude bits from being changed. Supported only for 32 bits fields +or smaller. .TP .I CONTROL The following keywords allow to control how the tree of qdisc, classes, diff --git a/tc/m_pedit.c b/tc/m_pedit.c index 7ef2acc52..9b74c9659 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -353,6 +353,12 @@ int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain, argv++; } + if (len > 4 && retain != ~0) { + fprintf(stderr, + "retain is not supported for fields longer the 32 bits\n"); + return -1; + } + if (type == TMAC) { res = pack_mac(sel, tkey, (__u8 *)val); goto done;