Commit e9c0d61d authored by David S. Miller's avatar David S. Miller

Merge branch 'ife'

Jamal Hadi Salim says:

====================
net_sched: Add support for IFE action

As agreed at netconf in Seville, here's the patch finally (1 year
was just too long to wait for an ethertype. Now we are just going
have the user configure one).
Described in netdev01 paper:
            "Distributing Linux Traffic Control Classifier-Action Subsystem"
             Authors: Jamal Hadi Salim and Damascene M. Joachimpillai

The original motivation and deployment of this work was to horizontally
scale packet processing at scope of a chasis or rack. This means one
could take a tc policy and split it across machines connected over
L2. The paper refers to this as "pipeline stage indexing". Other
use cases which evolved out of the original intent include but are
not limited to carrying OAM information, carrying exception handling
metadata, carrying programmed authentication and authorization information,
encapsulating programmed compliance information, service IDs etc.
Read the referenced paper for more details.

The architecture allows for incremental updates for new metadatum support
to cover different use cases.
This patch set includes support for basic skb metadatum.
Followup patches will have more examples of metadata and other features.

v4 changes:
Integrate more feedback from Cong

v3 changes:
Integrate with the new namespace changes
Remove skbhash and queue mapping metadata (but keep their claim for ids)
Integrate feedback from Cong
Integrate feedback from Daniel

v2 changes:
Remove module option for an upper bound of metadata
Integrate feedback from Cong
Integrate feedback from Daniel
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d67703fc 200e10f4
#ifndef __NET_TC_IFE_H
#define __NET_TC_IFE_H
#include <net/act_api.h>
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/module.h>
#define IFE_METAHDRLEN 2
struct tcf_ife_info {
struct tcf_common common;
u8 eth_dst[ETH_ALEN];
u8 eth_src[ETH_ALEN];
u16 eth_type;
u16 flags;
/* list of metaids allowed */
struct list_head metalist;
};
#define to_ife(a) \
container_of(a->priv, struct tcf_ife_info, common)
struct tcf_meta_info {
const struct tcf_meta_ops *ops;
void *metaval;
u16 metaid;
struct list_head metalist;
};
struct tcf_meta_ops {
u16 metaid; /*Maintainer provided ID */
u16 metatype; /*netlink attribute type (look at net/netlink.h) */
const char *name;
const char *synopsis;
struct list_head list;
int (*check_presence)(struct sk_buff *, struct tcf_meta_info *);
int (*encode)(struct sk_buff *, void *, struct tcf_meta_info *);
int (*decode)(struct sk_buff *, void *, u16 len);
int (*get)(struct sk_buff *skb, struct tcf_meta_info *mi);
int (*alloc)(struct tcf_meta_info *, void *);
void (*release)(struct tcf_meta_info *);
int (*validate)(void *val, int len);
struct module *owner;
};
#define MODULE_ALIAS_IFE_META(metan) MODULE_ALIAS("ifemeta" __stringify_1(metan))
int ife_get_meta_u32(struct sk_buff *skb, struct tcf_meta_info *mi);
int ife_get_meta_u16(struct sk_buff *skb, struct tcf_meta_info *mi);
int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen,
const void *dval);
int ife_alloc_meta_u32(struct tcf_meta_info *mi, void *metaval);
int ife_alloc_meta_u16(struct tcf_meta_info *mi, void *metaval);
int ife_check_meta_u32(u32 metaval, struct tcf_meta_info *mi);
int ife_encode_meta_u32(u32 metaval, void *skbdata, struct tcf_meta_info *mi);
int ife_validate_meta_u32(void *val, int len);
int ife_validate_meta_u16(void *val, int len);
void ife_release_meta_gen(struct tcf_meta_info *mi);
int register_ife_op(struct tcf_meta_ops *mops);
int unregister_ife_op(struct tcf_meta_ops *mops);
#endif /* __NET_TC_IFE_H */
#ifndef __UAPI_TC_IFE_H
#define __UAPI_TC_IFE_H
#include <linux/types.h>
#include <linux/pkt_cls.h>
#define TCA_ACT_IFE 25
/* Flag bits for now just encoding/decoding; mutually exclusive */
#define IFE_ENCODE 1
#define IFE_DECODE 0
struct tc_ife {
tc_gen;
__u16 flags;
};
/*XXX: We need to encode the total number of bytes consumed */
enum {
TCA_IFE_UNSPEC,
TCA_IFE_PARMS,
TCA_IFE_TM,
TCA_IFE_DMAC,
TCA_IFE_SMAC,
TCA_IFE_TYPE,
TCA_IFE_METALST,
__TCA_IFE_MAX
};
#define TCA_IFE_MAX (__TCA_IFE_MAX - 1)
#define IFE_META_SKBMARK 1
#define IFE_META_HASHID 2
#define IFE_META_PRIO 3
#define IFE_META_QMAP 4
/*Can be overridden at runtime by module option*/
#define __IFE_META_MAX 5
#define IFE_META_MAX (__IFE_META_MAX - 1)
#endif
......@@ -739,6 +739,28 @@ config NET_ACT_CONNMARK
To compile this code as a module, choose M here: the
module will be called act_connmark.
config NET_ACT_IFE
tristate "Inter-FE action based on IETF ForCES InterFE LFB"
depends on NET_CLS_ACT
---help---
Say Y here to allow for sourcing and terminating metadata
For details refer to netdev01 paper:
"Distributing Linux Traffic Control Classifier-Action Subsystem"
Authors: Jamal Hadi Salim and Damascene M. Joachimpillai
To compile this code as a module, choose M here: the
module will be called act_ife.
config NET_IFE_SKBMARK
tristate "Support to encoding decoding skb mark on IFE action"
depends on NET_ACT_IFE
---help---
config NET_IFE_SKBPRIO
tristate "Support to encoding decoding skb prio on IFE action"
depends on NET_ACT_IFE
---help---
config NET_CLS_IND
bool "Incoming device classification"
depends on NET_CLS_U32 || NET_CLS_FW
......
......@@ -19,6 +19,9 @@ obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o
obj-$(CONFIG_NET_ACT_VLAN) += act_vlan.o
obj-$(CONFIG_NET_ACT_BPF) += act_bpf.o
obj-$(CONFIG_NET_ACT_CONNMARK) += act_connmark.o
obj-$(CONFIG_NET_ACT_IFE) += act_ife.o
obj-$(CONFIG_NET_IFE_SKBMARK) += act_meta_mark.o
obj-$(CONFIG_NET_IFE_SKBPRIO) += act_meta_skbprio.o
obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
......
This diff is collapsed.
/*
* net/sched/act_meta_mark.c IFE skb->mark metadata module
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* copyright Jamal Hadi Salim (2015)
*
*/
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <linux/module.h>
#include <linux/init.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <uapi/linux/tc_act/tc_ife.h>
#include <net/tc_act/tc_ife.h>
#include <linux/rtnetlink.h>
static int skbmark_encode(struct sk_buff *skb, void *skbdata,
struct tcf_meta_info *e)
{
u32 ifemark = skb->mark;
return ife_encode_meta_u32(ifemark, skbdata, e);
}
static int skbmark_decode(struct sk_buff *skb, void *data, u16 len)
{
u32 ifemark = *(u32 *)data;
skb->mark = ntohl(ifemark);
return 0;
}
static int skbmark_check(struct sk_buff *skb, struct tcf_meta_info *e)
{
return ife_check_meta_u32(skb->mark, e);
}
static struct tcf_meta_ops ife_skbmark_ops = {
.metaid = IFE_META_SKBMARK,
.metatype = NLA_U32,
.name = "skbmark",
.synopsis = "skb mark 32 bit metadata",
.check_presence = skbmark_check,
.encode = skbmark_encode,
.decode = skbmark_decode,
.get = ife_get_meta_u32,
.alloc = ife_alloc_meta_u32,
.release = ife_release_meta_gen,
.validate = ife_validate_meta_u32,
.owner = THIS_MODULE,
};
static int __init ifemark_init_module(void)
{
return register_ife_op(&ife_skbmark_ops);
}
static void __exit ifemark_cleanup_module(void)
{
unregister_ife_op(&ife_skbmark_ops);
}
module_init(ifemark_init_module);
module_exit(ifemark_cleanup_module);
MODULE_AUTHOR("Jamal Hadi Salim(2015)");
MODULE_DESCRIPTION("Inter-FE skb mark metadata module");
MODULE_LICENSE("GPL");
MODULE_ALIAS_IFE_META(IFE_META_SKBMARK);
/*
* net/sched/act_meta_prio.c IFE skb->priority metadata module
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* copyright Jamal Hadi Salim (2015)
*
*/
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <linux/module.h>
#include <linux/init.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <uapi/linux/tc_act/tc_ife.h>
#include <net/tc_act/tc_ife.h>
static int skbprio_check(struct sk_buff *skb, struct tcf_meta_info *e)
{
return ife_check_meta_u32(skb->priority, e);
}
static int skbprio_encode(struct sk_buff *skb, void *skbdata,
struct tcf_meta_info *e)
{
u32 ifeprio = skb->priority; /* avoid having to cast skb->priority*/
return ife_encode_meta_u32(ifeprio, skbdata, e);
}
static int skbprio_decode(struct sk_buff *skb, void *data, u16 len)
{
u32 ifeprio = *(u32 *)data;
skb->priority = ntohl(ifeprio);
return 0;
}
static struct tcf_meta_ops ife_prio_ops = {
.metaid = IFE_META_PRIO,
.metatype = NLA_U32,
.name = "skbprio",
.synopsis = "skb prio metadata",
.check_presence = skbprio_check,
.encode = skbprio_encode,
.decode = skbprio_decode,
.get = ife_get_meta_u32,
.alloc = ife_alloc_meta_u32,
.owner = THIS_MODULE,
};
static int __init ifeprio_init_module(void)
{
return register_ife_op(&ife_prio_ops);
}
static void __exit ifeprio_cleanup_module(void)
{
unregister_ife_op(&ife_prio_ops);
}
module_init(ifeprio_init_module);
module_exit(ifeprio_cleanup_module);
MODULE_AUTHOR("Jamal Hadi Salim(2015)");
MODULE_DESCRIPTION("Inter-FE skb prio metadata action");
MODULE_LICENSE("GPL");
MODULE_ALIAS_IFE_META(IFE_META_PRIO);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment