diff mbox series

[iproute2,1/4] tc: m_ife: allow ife type to zero

Message ID 20170828190738.26829-2-aring@mojatatu.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show
Series tc: m_ife: handle IFE ethertype value | expand

Commit Message

Alexander Aring Aug. 28, 2017, 7:07 p.m. UTC
This patch allows to set an ethertype for IFE which is zero. There is no
kernel side validation which forbids a type to zero.

Signed-off-by: Alexander Aring <aring@mojatatu.com>
---
 tc/m_ife.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger Aug. 28, 2017, 7:34 p.m. UTC | #1
On Mon, 28 Aug 2017 15:07:35 -0400
Alexander Aring <aring@mojatatu.com> wrote:

> This patch allows to set an ethertype for IFE which is zero. There is no
> kernel side validation which forbids a type to zero.
> 
> Signed-off-by: Alexander Aring <aring@mojatatu.com>
> ---
>  tc/m_ife.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tc/m_ife.c b/tc/m_ife.c
> index e3521e62..e05e2276 100644
> --- a/tc/m_ife.c
> +++ b/tc/m_ife.c
> @@ -63,6 +63,7 @@ static int parse_ife(struct action_util *a, int *argc_p, char ***argv_p,
>  	char dbuf[ETH_ALEN];
>  	char sbuf[ETH_ALEN];
>  	__u16 ife_type = 0;
> +	int user_type = 0;

Please use bool if it is a flag value
Jamal Hadi Salim Aug. 28, 2017, 10:16 p.m. UTC | #2
On 17-08-28 03:07 PM, Alexander Aring wrote:
> This patch allows to set an ethertype for IFE which is zero. There is no
> kernel side validation which forbids a type to zero.
> 
> Signed-off-by: Alexander Aring <aring@mojatatu.com>

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

cheers,
jamal
diff mbox series

Patch

diff --git a/tc/m_ife.c b/tc/m_ife.c
index e3521e62..e05e2276 100644
--- a/tc/m_ife.c
+++ b/tc/m_ife.c
@@ -63,6 +63,7 @@  static int parse_ife(struct action_util *a, int *argc_p, char ***argv_p,
 	char dbuf[ETH_ALEN];
 	char sbuf[ETH_ALEN];
 	__u16 ife_type = 0;
+	int user_type = 0;
 	__u32 ife_prio = 0;
 	__u32 ife_prio_v = 0;
 	__u32 ife_mark = 0;
@@ -125,6 +126,7 @@  static int parse_ife(struct action_util *a, int *argc_p, char ***argv_p,
 			if (get_u16(&ife_type, *argv, 0))
 				invarg("ife type is invalid", *argv);
 			fprintf(stderr, "IFE type 0x%x\n", ife_type);
+			user_type = 1;
 		} else if (matches(*argv, "dst") == 0) {
 			NEXT_ARG();
 			daddr = *argv;
@@ -185,7 +187,7 @@  static int parse_ife(struct action_util *a, int *argc_p, char ***argv_p,
 
 	if (daddr)
 		addattr_l(n, MAX_MSG, TCA_IFE_DMAC, dbuf, ETH_ALEN);
-	if (ife_type)
+	if (user_type)
 		addattr_l(n, MAX_MSG, TCA_IFE_TYPE, &ife_type, 2);
 	if (saddr)
 		addattr_l(n, MAX_MSG, TCA_IFE_SMAC, sbuf, ETH_ALEN);