Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d23b8ad8 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

tc: add BPF based action



This action provides a possibility to exec custom BPF code.

Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 02dba438
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us>
 *
 * 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.
 */

#ifndef __NET_TC_BPF_H
#define __NET_TC_BPF_H

#include <linux/filter.h>
#include <net/act_api.h>

struct tcf_bpf {
	struct tcf_common	common;
	struct bpf_prog		*filter;
	struct sock_filter	*bpf_ops;
	u16			bpf_num_ops;
};
#define to_bpf(a) \
	container_of(a->priv, struct tcf_bpf, common)

#endif /* __NET_TC_BPF_H */
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ header-y += tc_nat.h
header-y += tc_pedit.h
header-y += tc_skbedit.h
header-y += tc_vlan.h
header-y += tc_bpf.h
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us>
 *
 * 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.
 */

#ifndef __LINUX_TC_BPF_H
#define __LINUX_TC_BPF_H

#include <linux/pkt_cls.h>

#define TCA_ACT_BPF 13

struct tc_act_bpf {
	tc_gen;
};

enum {
	TCA_ACT_BPF_UNSPEC,
	TCA_ACT_BPF_TM,
	TCA_ACT_BPF_PARMS,
	TCA_ACT_BPF_OPS_LEN,
	TCA_ACT_BPF_OPS,
	__TCA_ACT_BPF_MAX,
};
#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)

#endif
+12 −0
Original line number Diff line number Diff line
@@ -698,6 +698,18 @@ config NET_ACT_VLAN
	  To compile this code as a module, choose M here: the
	  module will be called act_vlan.

config NET_ACT_BPF
        tristate "BPF based action"
        depends on NET_CLS_ACT
        ---help---
	  Say Y here to execute BPF code on packets. The BPF code will decide
	  if the packet should be dropped or not.

	  If unsure, say N.

	  To compile this code as a module, choose M here: the
	  module will be called act_bpf.

config NET_CLS_IND
	bool "Incoming device classification"
	depends on NET_CLS_U32 || NET_CLS_FW
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o
obj-$(CONFIG_NET_ACT_SKBEDIT)	+= act_skbedit.o
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_SCH_FIFO)	+= sch_fifo.o
obj-$(CONFIG_NET_SCH_CBQ)	+= sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB)	+= sch_htb.o
Loading