act_meta_skbprio.c (1692B)
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * net/sched/act_meta_prio.c IFE skb->priority metadata module 4 * 5 * copyright Jamal Hadi Salim (2015) 6*/ 7 8#include <linux/types.h> 9#include <linux/kernel.h> 10#include <linux/string.h> 11#include <linux/errno.h> 12#include <linux/skbuff.h> 13#include <linux/rtnetlink.h> 14#include <linux/module.h> 15#include <linux/init.h> 16#include <net/netlink.h> 17#include <net/pkt_sched.h> 18#include <uapi/linux/tc_act/tc_ife.h> 19#include <net/tc_act/tc_ife.h> 20 21static int skbprio_check(struct sk_buff *skb, struct tcf_meta_info *e) 22{ 23 return ife_check_meta_u32(skb->priority, e); 24} 25 26static int skbprio_encode(struct sk_buff *skb, void *skbdata, 27 struct tcf_meta_info *e) 28{ 29 u32 ifeprio = skb->priority; /* avoid having to cast skb->priority*/ 30 31 return ife_encode_meta_u32(ifeprio, skbdata, e); 32} 33 34static int skbprio_decode(struct sk_buff *skb, void *data, u16 len) 35{ 36 u32 ifeprio = *(u32 *)data; 37 38 skb->priority = ntohl(ifeprio); 39 return 0; 40} 41 42static struct tcf_meta_ops ife_prio_ops = { 43 .metaid = IFE_META_PRIO, 44 .metatype = NLA_U32, 45 .name = "skbprio", 46 .synopsis = "skb prio metadata", 47 .check_presence = skbprio_check, 48 .encode = skbprio_encode, 49 .decode = skbprio_decode, 50 .get = ife_get_meta_u32, 51 .alloc = ife_alloc_meta_u32, 52 .owner = THIS_MODULE, 53}; 54 55static int __init ifeprio_init_module(void) 56{ 57 return register_ife_op(&ife_prio_ops); 58} 59 60static void __exit ifeprio_cleanup_module(void) 61{ 62 unregister_ife_op(&ife_prio_ops); 63} 64 65module_init(ifeprio_init_module); 66module_exit(ifeprio_cleanup_module); 67 68MODULE_AUTHOR("Jamal Hadi Salim(2015)"); 69MODULE_DESCRIPTION("Inter-FE skb prio metadata action"); 70MODULE_LICENSE("GPL"); 71MODULE_ALIAS_IFE_META("skbprio");