aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-09-29 19:41:51 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-03 08:02:41 -0400
commitc46646d0484f5d08e2bede9b45034ba5b8b489cc (patch)
treeb15b5132baba1198decf5966819dea7cdb7d2cfc /net/sched
parenta91263d520246b63c63e75ddfb072ee6a853fe15 (diff)
sched, bpf: add helper for retrieving routing realms
Using routing realms as part of the classifier is quite useful, it can be viewed as a tag for one or multiple routing entries (think of an analogy to net_cls cgroup for processes), set by user space routing daemons or via iproute2 as an indicator for traffic classifiers and later on processed in the eBPF program. Unlike actions, the classifier can inspect device flags and enable netif_keep_dst() if necessary. tc actions don't have that possibility, but in case people know what they are doing, it can be used from there as well (e.g. via devs that must keep dsts by design anyway). If a realm is set, the handler returns the non-zero realm. User space can set the full 32bit realm for the dst. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/cls_bpf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 7eeffaf69c75..5faaa5425f7b 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -262,7 +262,8 @@ static int cls_bpf_prog_from_ops(struct nlattr **tb, struct cls_bpf_prog *prog)
262 return 0; 262 return 0;
263} 263}
264 264
265static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog) 265static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog,
266 const struct tcf_proto *tp)
266{ 267{
267 struct bpf_prog *fp; 268 struct bpf_prog *fp;
268 char *name = NULL; 269 char *name = NULL;
@@ -294,6 +295,9 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog)
294 prog->bpf_name = name; 295 prog->bpf_name = name;
295 prog->filter = fp; 296 prog->filter = fp;
296 297
298 if (fp->dst_needed)
299 netif_keep_dst(qdisc_dev(tp->q));
300
297 return 0; 301 return 0;
298} 302}
299 303
@@ -330,7 +334,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
330 prog->exts_integrated = have_exts; 334 prog->exts_integrated = have_exts;
331 335
332 ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) : 336 ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) :
333 cls_bpf_prog_from_efd(tb, prog); 337 cls_bpf_prog_from_efd(tb, prog, tp);
334 if (ret < 0) { 338 if (ret < 0) {
335 tcf_exts_destroy(&exts); 339 tcf_exts_destroy(&exts);
336 return ret; 340 return ret;