summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-02-01 17:45:39 +0100
committerTobias Klauser <tklauser@distanz.ch>2016-02-01 17:45:39 +0100
commit52b1f5dd3c60aa008e0538d7f8abda4727b6a9df (patch)
treeb73a405e6fc550972f270160c1008513314f5d2b
parent23492a017a2df510d054157ba314d1e6b1a43c3c (diff)
trafgen: parser: Fix parsing of "prot[o]" field in eth()
Commit 2ba202b introduced the [e]type field for specifiying the Ethertype, but at the same time made the existing "prot[o]" field name not work anymore. Fix it by providing a specific parser rule as it cannot be solved in the lexer grammar alone (which will always use the first matching token). Fixes: 2ba202b ("trafgen: parser: Support "etype"/"type" keywords for Ethertype") Reported-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--trafgen_lexer.l3
-rw-r--r--trafgen_parser.y7
2 files changed, 7 insertions, 3 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index 83e7602..ef7ec2a 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -105,13 +105,12 @@ ip4_addr ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)
"const32"|"c32" { return K_CONST32; }
"const64"|"c64" { return K_CONST64; }
- /* IPv4 proto field (must be before more specific rule for K_ETYPE) */
"prot"[o]? { return K_PROT; }
/* Ethernet */
"daddr"|"da" { return K_DADDR; }
"saddr"|"sa" { return K_SADDR; }
-[e]?"type"|"prot"[o]? { return K_ETYPE; }
+[e]?"type" { return K_ETYPE; }
/* ARP */
"sha"|"smac" { return K_SHA; }
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 7387c14..1bacfd0 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -600,12 +600,17 @@ eth_param_list
| eth_field delimiter eth_param_list { }
;
+eth_type
+ : K_ETYPE { }
+ | K_PROT {}
+ ;
+
eth_field
: K_DADDR skip_white '=' skip_white mac
{ proto_field_set_bytes(hdr, ETH_DST_ADDR, $5); }
| K_SADDR skip_white '=' skip_white mac
{ proto_field_set_bytes(hdr, ETH_SRC_ADDR, $5); }
- | K_ETYPE skip_white '=' skip_white number
+ | eth_type skip_white '=' skip_white number
{ proto_field_set_be16(hdr, ETH_TYPE, $5); }
;