|
49 | 49 | #include <net/sch_generic.h>
|
50 | 50 | #include <net/cls_cgroup.h>
|
51 | 51 | #include <net/dst_metadata.h>
|
| 52 | +#include <net/dst.h> |
52 | 53 |
|
53 | 54 | /**
|
54 | 55 | * sk_filter - run a packet through a socket filter
|
@@ -1478,6 +1479,25 @@ static const struct bpf_func_proto bpf_get_cgroup_classid_proto = {
|
1478 | 1479 | .arg1_type = ARG_PTR_TO_CTX,
|
1479 | 1480 | };
|
1480 | 1481 |
|
| 1482 | +static u64 bpf_get_route_realm(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) |
| 1483 | +{ |
| 1484 | +#ifdef CONFIG_IP_ROUTE_CLASSID |
| 1485 | + const struct dst_entry *dst; |
| 1486 | + |
| 1487 | + dst = skb_dst((struct sk_buff *) (unsigned long) r1); |
| 1488 | + if (dst) |
| 1489 | + return dst->tclassid; |
| 1490 | +#endif |
| 1491 | + return 0; |
| 1492 | +} |
| 1493 | + |
| 1494 | +static const struct bpf_func_proto bpf_get_route_realm_proto = { |
| 1495 | + .func = bpf_get_route_realm, |
| 1496 | + .gpl_only = false, |
| 1497 | + .ret_type = RET_INTEGER, |
| 1498 | + .arg1_type = ARG_PTR_TO_CTX, |
| 1499 | +}; |
| 1500 | + |
1481 | 1501 | static u64 bpf_skb_vlan_push(u64 r1, u64 r2, u64 vlan_tci, u64 r4, u64 r5)
|
1482 | 1502 | {
|
1483 | 1503 | struct sk_buff *skb = (struct sk_buff *) (long) r1;
|
@@ -1648,6 +1668,8 @@ tc_cls_act_func_proto(enum bpf_func_id func_id)
|
1648 | 1668 | return bpf_get_skb_set_tunnel_key_proto();
|
1649 | 1669 | case BPF_FUNC_redirect:
|
1650 | 1670 | return &bpf_redirect_proto;
|
| 1671 | + case BPF_FUNC_get_route_realm: |
| 1672 | + return &bpf_get_route_realm_proto; |
1651 | 1673 | default:
|
1652 | 1674 | return sk_filter_func_proto(func_id);
|
1653 | 1675 | }
|
|
0 commit comments