* [iproute2-next] tc flower: use right ethertype in icmp/arp parsing
@ 2020-10-19 11:47 Zahari Doychev
2020-10-25 21:18 ` David Ahern
0 siblings, 1 reply; 5+ messages in thread
From: Zahari Doychev @ 2020-10-19 11:47 UTC (permalink / raw)
To: netdev; +Cc: dsahern, simon.horman, jhs, Zahari Doychev
Currently the icmp and arp prsing functions are called with inccorect
ethtype in case of vlan or cvlan filter options. In this case either
cvlan_ethtype or vlan_ethtype has to be used.
Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
---
tc/f_flower.c | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 00c919fd..dd9f3446 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1712,7 +1712,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
}
} else if (matches(*argv, "type") == 0) {
NEXT_ARG();
- ret = flower_parse_icmp(*argv, eth_type, ip_proto,
+ ret = flower_parse_icmp(*argv, cvlan_ethtype ?
+ cvlan_ethtype : vlan_ethtype ?
+ vlan_ethtype : eth_type,
+ ip_proto,
FLOWER_ICMP_FIELD_TYPE, n);
if (ret < 0) {
fprintf(stderr, "Illegal \"icmp type\"\n");
@@ -1720,7 +1723,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
}
} else if (matches(*argv, "code") == 0) {
NEXT_ARG();
- ret = flower_parse_icmp(*argv, eth_type, ip_proto,
+ ret = flower_parse_icmp(*argv, cvlan_ethtype ?
+ cvlan_ethtype : vlan_ethtype ?
+ vlan_ethtype : eth_type,
+ ip_proto,
FLOWER_ICMP_FIELD_CODE, n);
if (ret < 0) {
fprintf(stderr, "Illegal \"icmp code\"\n");
@@ -1728,33 +1734,36 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
}
} else if (matches(*argv, "arp_tip") == 0) {
NEXT_ARG();
- ret = flower_parse_arp_ip_addr(*argv, vlan_ethtype ?
- vlan_ethtype : eth_type,
- TCA_FLOWER_KEY_ARP_TIP,
- TCA_FLOWER_KEY_ARP_TIP_MASK,
- n);
+ ret = flower_parse_arp_ip_addr(*argv, cvlan_ethtype ?
+ cvlan_ethtype : vlan_ethtype ?
+ vlan_ethtype : eth_type,
+ TCA_FLOWER_KEY_ARP_TIP,
+ TCA_FLOWER_KEY_ARP_TIP_MASK,
+ n);
if (ret < 0) {
fprintf(stderr, "Illegal \"arp_tip\"\n");
return -1;
}
} else if (matches(*argv, "arp_sip") == 0) {
NEXT_ARG();
- ret = flower_parse_arp_ip_addr(*argv, vlan_ethtype ?
- vlan_ethtype : eth_type,
- TCA_FLOWER_KEY_ARP_SIP,
- TCA_FLOWER_KEY_ARP_SIP_MASK,
- n);
+ ret = flower_parse_arp_ip_addr(*argv, cvlan_ethtype ?
+ cvlan_ethtype : vlan_ethtype ?
+ vlan_ethtype : eth_type,
+ TCA_FLOWER_KEY_ARP_SIP,
+ TCA_FLOWER_KEY_ARP_SIP_MASK,
+ n);
if (ret < 0) {
fprintf(stderr, "Illegal \"arp_sip\"\n");
return -1;
}
} else if (matches(*argv, "arp_op") == 0) {
NEXT_ARG();
- ret = flower_parse_arp_op(*argv, vlan_ethtype ?
- vlan_ethtype : eth_type,
- TCA_FLOWER_KEY_ARP_OP,
- TCA_FLOWER_KEY_ARP_OP_MASK,
- n);
+ ret = flower_parse_arp_op(*argv, cvlan_ethtype ?
+ cvlan_ethtype : vlan_ethtype ?
+ vlan_ethtype : eth_type,
+ TCA_FLOWER_KEY_ARP_OP,
+ TCA_FLOWER_KEY_ARP_OP_MASK,
+ n);
if (ret < 0) {
fprintf(stderr, "Illegal \"arp_op\"\n");
return -1;
--
2.28.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [iproute2-next] tc flower: use right ethertype in icmp/arp parsing
2020-10-19 11:47 [iproute2-next] tc flower: use right ethertype in icmp/arp parsing Zahari Doychev
@ 2020-10-25 21:18 ` David Ahern
2020-10-26 8:48 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: David Ahern @ 2020-10-25 21:18 UTC (permalink / raw)
To: Zahari Doychev, netdev; +Cc: simon.horman, jhs
On 10/19/20 5:47 AM, Zahari Doychev wrote:
> Currently the icmp and arp prsing functions are called with inccorect
> ethtype in case of vlan or cvlan filter options. In this case either
> cvlan_ethtype or vlan_ethtype has to be used.
>
> Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
> ---
> tc/f_flower.c | 43 ++++++++++++++++++++++++++-----------------
> 1 file changed, 26 insertions(+), 17 deletions(-)
>
> diff --git a/tc/f_flower.c b/tc/f_flower.c
> index 00c919fd..dd9f3446 100644
> --- a/tc/f_flower.c
> +++ b/tc/f_flower.c
> @@ -1712,7 +1712,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
> }
> } else if (matches(*argv, "type") == 0) {
> NEXT_ARG();
> - ret = flower_parse_icmp(*argv, eth_type, ip_proto,
> + ret = flower_parse_icmp(*argv, cvlan_ethtype ?
> + cvlan_ethtype : vlan_ethtype ?
> + vlan_ethtype : eth_type,
> + ip_proto,
looks correct to me, but would like confirmation of the intent from Simon.
Also, I am not a fan of the readability of that coding style. Rather
than repeat that expression multiple times, make a short helper to
return the relevant eth type and use a temp variable for it. You should
also comment that relevant eth type changes as arguments are parsed.
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [iproute2-next] tc flower: use right ethertype in icmp/arp parsing
2020-10-25 21:18 ` David Ahern
@ 2020-10-26 8:48 ` Simon Horman
2020-10-27 9:11 ` Zahari Doychev
0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2020-10-26 8:48 UTC (permalink / raw)
To: David Ahern; +Cc: Zahari Doychev, netdev, jhs
On Sun, Oct 25, 2020 at 03:18:48PM -0600, David Ahern wrote:
> On 10/19/20 5:47 AM, Zahari Doychev wrote:
> > Currently the icmp and arp prsing functions are called with inccorect
> > ethtype in case of vlan or cvlan filter options. In this case either
> > cvlan_ethtype or vlan_ethtype has to be used.
> >
> > Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
> > ---
> > tc/f_flower.c | 43 ++++++++++++++++++++++++++-----------------
> > 1 file changed, 26 insertions(+), 17 deletions(-)
> >
> > diff --git a/tc/f_flower.c b/tc/f_flower.c
> > index 00c919fd..dd9f3446 100644
> > --- a/tc/f_flower.c
> > +++ b/tc/f_flower.c
> > @@ -1712,7 +1712,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
> > }
> > } else if (matches(*argv, "type") == 0) {
> > NEXT_ARG();
> > - ret = flower_parse_icmp(*argv, eth_type, ip_proto,
> > + ret = flower_parse_icmp(*argv, cvlan_ethtype ?
> > + cvlan_ethtype : vlan_ethtype ?
> > + vlan_ethtype : eth_type,
> > + ip_proto,
>
> looks correct to me, but would like confirmation of the intent from Simon.
Thanks, this appears to be correct to me as ultimately
the code wants to operate on ETH_P_IP or ETH_P_IPV6 rather
than a VLAN Ether type.
> Also, I am not a fan of the readability of that coding style. Rather
> than repeat that expression multiple times, make a short helper to
> return the relevant eth type and use a temp variable for it. You should
> also comment that relevant eth type changes as arguments are parsed.
>
> Thanks,
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [iproute2-next] tc flower: use right ethertype in icmp/arp parsing
2020-10-26 8:48 ` Simon Horman
@ 2020-10-27 9:11 ` Zahari Doychev
2020-10-27 14:12 ` David Ahern
0 siblings, 1 reply; 5+ messages in thread
From: Zahari Doychev @ 2020-10-27 9:11 UTC (permalink / raw)
To: Simon Horman; +Cc: David Ahern, netdev, jhs
On Mon, Oct 26, 2020 at 09:48:24AM +0100, Simon Horman wrote:
> On Sun, Oct 25, 2020 at 03:18:48PM -0600, David Ahern wrote:
> > On 10/19/20 5:47 AM, Zahari Doychev wrote:
> > > Currently the icmp and arp prsing functions are called with inccorect
> > > ethtype in case of vlan or cvlan filter options. In this case either
> > > cvlan_ethtype or vlan_ethtype has to be used.
> > >
> > > Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
> > > ---
> > > tc/f_flower.c | 43 ++++++++++++++++++++++++++-----------------
> > > 1 file changed, 26 insertions(+), 17 deletions(-)
> > >
> > > diff --git a/tc/f_flower.c b/tc/f_flower.c
> > > index 00c919fd..dd9f3446 100644
> > > --- a/tc/f_flower.c
> > > +++ b/tc/f_flower.c
> > > @@ -1712,7 +1712,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
> > > }
> > > } else if (matches(*argv, "type") == 0) {
> > > NEXT_ARG();
> > > - ret = flower_parse_icmp(*argv, eth_type, ip_proto,
> > > + ret = flower_parse_icmp(*argv, cvlan_ethtype ?
> > > + cvlan_ethtype : vlan_ethtype ?
> > > + vlan_ethtype : eth_type,
> > > + ip_proto,
> >
> > looks correct to me, but would like confirmation of the intent from Simon.
>
> Thanks, this appears to be correct to me as ultimately
> the code wants to operate on ETH_P_IP or ETH_P_IPV6 rather
> than a VLAN Ether type.
>
> > Also, I am not a fan of the readability of that coding style. Rather
> > than repeat that expression multiple times, make a short helper to
> > return the relevant eth type and use a temp variable for it. You should
> > also comment that relevant eth type changes as arguments are parsed.
I will add the helper and resend.
Thanks Zahari
> >
> > Thanks,
> >
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [iproute2-next] tc flower: use right ethertype in icmp/arp parsing
2020-10-27 9:11 ` Zahari Doychev
@ 2020-10-27 14:12 ` David Ahern
0 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2020-10-27 14:12 UTC (permalink / raw)
To: Zahari Doychev, Simon Horman; +Cc: netdev, jhs
On 10/27/20 3:11 AM, Zahari Doychev wrote:
> On Mon, Oct 26, 2020 at 09:48:24AM +0100, Simon Horman wrote:
>> On Sun, Oct 25, 2020 at 03:18:48PM -0600, David Ahern wrote:
>>> On 10/19/20 5:47 AM, Zahari Doychev wrote:
>>>> Currently the icmp and arp prsing functions are called with inccorect
>>>> ethtype in case of vlan or cvlan filter options. In this case either
>>>> cvlan_ethtype or vlan_ethtype has to be used.
>>>>
>>>> Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
>>>> ---
>>>> tc/f_flower.c | 43 ++++++++++++++++++++++++++-----------------
>>>> 1 file changed, 26 insertions(+), 17 deletions(-)
>>>>
>>>> diff --git a/tc/f_flower.c b/tc/f_flower.c
>>>> index 00c919fd..dd9f3446 100644
>>>> --- a/tc/f_flower.c
>>>> +++ b/tc/f_flower.c
>>>> @@ -1712,7 +1712,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
>>>> }
>>>> } else if (matches(*argv, "type") == 0) {
>>>> NEXT_ARG();
>>>> - ret = flower_parse_icmp(*argv, eth_type, ip_proto,
>>>> + ret = flower_parse_icmp(*argv, cvlan_ethtype ?
>>>> + cvlan_ethtype : vlan_ethtype ?
>>>> + vlan_ethtype : eth_type,
>>>> + ip_proto,
>>>
>>> looks correct to me, but would like confirmation of the intent from Simon.
>>
>> Thanks, this appears to be correct to me as ultimately
>> the code wants to operate on ETH_P_IP or ETH_P_IPV6 rather
>> than a VLAN Ether type.
>>
>>> Also, I am not a fan of the readability of that coding style. Rather
>>> than repeat that expression multiple times, make a short helper to
>>> return the relevant eth type and use a temp variable for it. You should
>>> also comment that relevant eth type changes as arguments are parsed.
>
> I will add the helper and resend.
>
perhaps it is simpler to have a new local variable that tracks the eth
type to be used in these locations.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-27 18:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 11:47 [iproute2-next] tc flower: use right ethertype in icmp/arp parsing Zahari Doychev
2020-10-25 21:18 ` David Ahern
2020-10-26 8:48 ` Simon Horman
2020-10-27 9:11 ` Zahari Doychev
2020-10-27 14:12 ` David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).