aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/em_meta.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/em_meta.c')
-rw-r--r--net/sched/em_meta.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 3bcac8aa333c..49130e8abff0 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -47,7 +47,7 @@
47 * on the meta type. Obviously, the length of the data must also 47 * on the meta type. Obviously, the length of the data must also
48 * be provided for non-numeric types. 48 * be provided for non-numeric types.
49 * 49 *
50 * Additionaly, type dependant modifiers such as shift operators 50 * Additionally, type dependent modifiers such as shift operators
51 * or mask may be applied to extend the functionaliy. As of now, 51 * or mask may be applied to extend the functionaliy. As of now,
52 * the variable length type supports shifting the byte string to 52 * the variable length type supports shifting the byte string to
53 * the right, eating up any number of octets and thus supporting 53 * the right, eating up any number of octets and thus supporting
@@ -73,21 +73,18 @@
73#include <net/pkt_cls.h> 73#include <net/pkt_cls.h>
74#include <net/sock.h> 74#include <net/sock.h>
75 75
76struct meta_obj 76struct meta_obj {
77{
78 unsigned long value; 77 unsigned long value;
79 unsigned int len; 78 unsigned int len;
80}; 79};
81 80
82struct meta_value 81struct meta_value {
83{
84 struct tcf_meta_val hdr; 82 struct tcf_meta_val hdr;
85 unsigned long val; 83 unsigned long val;
86 unsigned int len; 84 unsigned int len;
87}; 85};
88 86
89struct meta_match 87struct meta_match {
90{
91 struct meta_value lvalue; 88 struct meta_value lvalue;
92 struct meta_value rvalue; 89 struct meta_value rvalue;
93}; 90};
@@ -223,6 +220,11 @@ META_COLLECTOR(int_maclen)
223 dst->value = skb->mac_len; 220 dst->value = skb->mac_len;
224} 221}
225 222
223META_COLLECTOR(int_rxhash)
224{
225 dst->value = skb_get_rxhash(skb);
226}
227
226/************************************************************************** 228/**************************************************************************
227 * Netfilter 229 * Netfilter
228 **************************************************************************/ 230 **************************************************************************/
@@ -250,7 +252,7 @@ META_COLLECTOR(int_rtclassid)
250 if (unlikely(skb_dst(skb) == NULL)) 252 if (unlikely(skb_dst(skb) == NULL))
251 *err = -1; 253 *err = -1;
252 else 254 else
253#ifdef CONFIG_NET_CLS_ROUTE 255#ifdef CONFIG_IP_ROUTE_CLASSID
254 dst->value = skb_dst(skb)->tclassid; 256 dst->value = skb_dst(skb)->tclassid;
255#else 257#else
256 dst->value = 0; 258 dst->value = 0;
@@ -262,7 +264,7 @@ META_COLLECTOR(int_rtiif)
262 if (unlikely(skb_rtable(skb) == NULL)) 264 if (unlikely(skb_rtable(skb) == NULL))
263 *err = -1; 265 *err = -1;
264 else 266 else
265 dst->value = skb_rtable(skb)->fl.iif; 267 dst->value = skb_rtable(skb)->rt_iif;
266} 268}
267 269
268/************************************************************************** 270/**************************************************************************
@@ -399,7 +401,7 @@ META_COLLECTOR(int_sk_sndbuf)
399META_COLLECTOR(int_sk_alloc) 401META_COLLECTOR(int_sk_alloc)
400{ 402{
401 SKIP_NONLOCAL(skb); 403 SKIP_NONLOCAL(skb);
402 dst->value = skb->sk->sk_allocation; 404 dst->value = (__force int) skb->sk->sk_allocation;
403} 405}
404 406
405META_COLLECTOR(int_sk_route_caps) 407META_COLLECTOR(int_sk_route_caps)
@@ -478,8 +480,7 @@ META_COLLECTOR(int_sk_write_pend)
478 * Meta value collectors assignment table 480 * Meta value collectors assignment table
479 **************************************************************************/ 481 **************************************************************************/
480 482
481struct meta_ops 483struct meta_ops {
482{
483 void (*get)(struct sk_buff *, struct tcf_pkt_info *, 484 void (*get)(struct sk_buff *, struct tcf_pkt_info *,
484 struct meta_value *, struct meta_obj *, int *); 485 struct meta_value *, struct meta_obj *, int *);
485}; 486};
@@ -489,7 +490,7 @@ struct meta_ops
489 490
490/* Meta value operations table listing all meta value collectors and 491/* Meta value operations table listing all meta value collectors and
491 * assigns them to a type and meta id. */ 492 * assigns them to a type and meta id. */
492static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { 493static struct meta_ops __meta_ops[TCF_META_TYPE_MAX + 1][TCF_META_ID_MAX + 1] = {
493 [TCF_META_TYPE_VAR] = { 494 [TCF_META_TYPE_VAR] = {
494 [META_ID(DEV)] = META_FUNC(var_dev), 495 [META_ID(DEV)] = META_FUNC(var_dev),
495 [META_ID(SK_BOUND_IF)] = META_FUNC(var_sk_bound_if), 496 [META_ID(SK_BOUND_IF)] = META_FUNC(var_sk_bound_if),
@@ -541,10 +542,11 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
541 [META_ID(SK_SENDMSG_OFF)] = META_FUNC(int_sk_sendmsg_off), 542 [META_ID(SK_SENDMSG_OFF)] = META_FUNC(int_sk_sendmsg_off),
542 [META_ID(SK_WRITE_PENDING)] = META_FUNC(int_sk_write_pend), 543 [META_ID(SK_WRITE_PENDING)] = META_FUNC(int_sk_write_pend),
543 [META_ID(VLAN_TAG)] = META_FUNC(int_vlan_tag), 544 [META_ID(VLAN_TAG)] = META_FUNC(int_vlan_tag),
545 [META_ID(RXHASH)] = META_FUNC(int_rxhash),
544 } 546 }
545}; 547};
546 548
547static inline struct meta_ops * meta_ops(struct meta_value *val) 549static inline struct meta_ops *meta_ops(struct meta_value *val)
548{ 550{
549 return &__meta_ops[meta_type(val)][meta_id(val)]; 551 return &__meta_ops[meta_type(val)][meta_id(val)];
550} 552}
@@ -643,9 +645,8 @@ static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv)
643{ 645{
644 if (v->len == sizeof(unsigned long)) 646 if (v->len == sizeof(unsigned long))
645 NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val); 647 NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val);
646 else if (v->len == sizeof(u32)) { 648 else if (v->len == sizeof(u32))
647 NLA_PUT_U32(skb, tlv, v->val); 649 NLA_PUT_U32(skb, tlv, v->val);
648 }
649 650
650 return 0; 651 return 0;
651 652
@@ -657,8 +658,7 @@ nla_put_failure:
657 * Type specific operations table 658 * Type specific operations table
658 **************************************************************************/ 659 **************************************************************************/
659 660
660struct meta_type_ops 661struct meta_type_ops {
661{
662 void (*destroy)(struct meta_value *); 662 void (*destroy)(struct meta_value *);
663 int (*compare)(struct meta_obj *, struct meta_obj *); 663 int (*compare)(struct meta_obj *, struct meta_obj *);
664 int (*change)(struct meta_value *, struct nlattr *); 664 int (*change)(struct meta_value *, struct nlattr *);
@@ -666,7 +666,7 @@ struct meta_type_ops
666 int (*dump)(struct sk_buff *, struct meta_value *, int); 666 int (*dump)(struct sk_buff *, struct meta_value *, int);
667}; 667};
668 668
669static struct meta_type_ops __meta_type_ops[TCF_META_TYPE_MAX+1] = { 669static struct meta_type_ops __meta_type_ops[TCF_META_TYPE_MAX + 1] = {
670 [TCF_META_TYPE_VAR] = { 670 [TCF_META_TYPE_VAR] = {
671 .destroy = meta_var_destroy, 671 .destroy = meta_var_destroy,
672 .compare = meta_var_compare, 672 .compare = meta_var_compare,
@@ -682,7 +682,7 @@ static struct meta_type_ops __meta_type_ops[TCF_META_TYPE_MAX+1] = {
682 } 682 }
683}; 683};
684 684
685static inline struct meta_type_ops * meta_type_ops(struct meta_value *v) 685static inline struct meta_type_ops *meta_type_ops(struct meta_value *v)
686{ 686{
687 return &__meta_type_ops[meta_type(v)]; 687 return &__meta_type_ops[meta_type(v)];
688} 688}
@@ -707,7 +707,7 @@ static int meta_get(struct sk_buff *skb, struct tcf_pkt_info *info,
707 return err; 707 return err;
708 708
709 if (meta_type_ops(v)->apply_extras) 709 if (meta_type_ops(v)->apply_extras)
710 meta_type_ops(v)->apply_extras(v, dst); 710 meta_type_ops(v)->apply_extras(v, dst);
711 711
712 return 0; 712 return 0;
713} 713}
@@ -726,12 +726,12 @@ static int em_meta_match(struct sk_buff *skb, struct tcf_ematch *m,
726 r = meta_type_ops(&meta->lvalue)->compare(&l_value, &r_value); 726 r = meta_type_ops(&meta->lvalue)->compare(&l_value, &r_value);
727 727
728 switch (meta->lvalue.hdr.op) { 728 switch (meta->lvalue.hdr.op) {
729 case TCF_EM_OPND_EQ: 729 case TCF_EM_OPND_EQ:
730 return !r; 730 return !r;
731 case TCF_EM_OPND_LT: 731 case TCF_EM_OPND_LT:
732 return r < 0; 732 return r < 0;
733 case TCF_EM_OPND_GT: 733 case TCF_EM_OPND_GT:
734 return r > 0; 734 return r > 0;
735 } 735 }
736 736
737 return 0; 737 return 0;
@@ -765,7 +765,7 @@ static inline int meta_change_data(struct meta_value *dst, struct nlattr *nla)
765 765
766static inline int meta_is_supported(struct meta_value *val) 766static inline int meta_is_supported(struct meta_value *val)
767{ 767{
768 return (!meta_id(val) || meta_ops(val)->get); 768 return !meta_id(val) || meta_ops(val)->get;
769} 769}
770 770
771static const struct nla_policy meta_policy[TCA_EM_META_MAX + 1] = { 771static const struct nla_policy meta_policy[TCA_EM_META_MAX + 1] = {