diff options
author | Jamal Hadi Salim <jhs@mojatatu.com> | 2016-09-18 07:31:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-19 21:55:28 -0400 |
commit | 6a5d58b67e205f2ffc62d0a9ee4ef7d237e9a7fb (patch) | |
tree | 81b3772aa9d8208c22abd93029193eda03f95f70 /net/sched | |
parent | 766a0e978fc2ba98d4865b466f8b572402317189 (diff) | |
download | linux-6a5d58b67e205f2ffc62d0a9ee4ef7d237e9a7fb.tar.gz linux-6a5d58b67e205f2ffc62d0a9ee4ef7d237e9a7fb.tar.bz2 linux-6a5d58b67e205f2ffc62d0a9ee4ef7d237e9a7fb.zip |
net sched ife action: add 16 bit helpers
encoder and checker for 16 bits metadata
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/act_ife.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index e87cd81315e1..ccf7b4b655fe 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -63,6 +63,23 @@ int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen, const void *dval) } EXPORT_SYMBOL_GPL(ife_tlv_meta_encode); +int ife_encode_meta_u16(u16 metaval, void *skbdata, struct tcf_meta_info *mi) +{ + u16 edata = 0; + + if (mi->metaval) + edata = *(u16 *)mi->metaval; + else if (metaval) + edata = metaval; + + if (!edata) /* will not encode */ + return 0; + + edata = htons(edata); + return ife_tlv_meta_encode(skbdata, mi->metaid, 2, &edata); +} +EXPORT_SYMBOL_GPL(ife_encode_meta_u16); + int ife_get_meta_u32(struct sk_buff *skb, struct tcf_meta_info *mi) { if (mi->metaval) @@ -81,6 +98,15 @@ int ife_check_meta_u32(u32 metaval, struct tcf_meta_info *mi) } EXPORT_SYMBOL_GPL(ife_check_meta_u32); +int ife_check_meta_u16(u16 metaval, struct tcf_meta_info *mi) +{ + if (metaval || mi->metaval) + return 8; /* T+L+(V) == 2+2+(2+2bytepad) */ + + return 0; +} +EXPORT_SYMBOL_GPL(ife_check_meta_u16); + int ife_encode_meta_u32(u32 metaval, void *skbdata, struct tcf_meta_info *mi) { u32 edata = metaval; |