Fix attaching program failure on kernel 5.10 am: 3c94994650 am: dc0ec70f3f

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697147

Change-Id: Ia8e6302907d0115f92cd1186ea626dd1115a131e
This commit is contained in:
Hungming Chen
2021-05-06 07:30:44 +00:00
committed by Automerger Merge Worker

View File

@@ -36,6 +36,9 @@
// The maximum length of TCA_BPF_NAME. Sync from net/sched/cls_bpf.c. // The maximum length of TCA_BPF_NAME. Sync from net/sched/cls_bpf.c.
#define CLS_BPF_NAME_LEN 256 #define CLS_BPF_NAME_LEN 256
// Classifier name. See cls_bpf_ops in net/sched/cls_bpf.c.
#define CLS_BPF_KIND_NAME "bpf"
namespace android { namespace android {
// Sync from system/netd/server/NetlinkCommands.h // Sync from system/netd/server/NetlinkCommands.h
const uint16_t NETLINK_REQUEST_FLAGS = NLM_F_REQUEST | NLM_F_ACK; const uint16_t NETLINK_REQUEST_FLAGS = NLM_F_REQUEST | NLM_F_ACK;
@@ -205,9 +208,9 @@ static void com_android_networkstack_tethering_BpfUtils_tcFilterAddDevBpf(
tcmsg t; tcmsg t;
struct { struct {
nlattr attr; nlattr attr;
// The maximum classifier name length is defined as IFNAMSIZ. // The maximum classifier name length is defined in
// See tcf_proto_ops in include/net/sch_generic.h. // tcf_proto_ops in include/net/sch_generic.h.
char str[NLMSG_ALIGN(IFNAMSIZ)]; char str[NLMSG_ALIGN(sizeof(CLS_BPF_KIND_NAME))];
} kind; } kind;
struct { struct {
nlattr attr; nlattr attr;
@@ -248,8 +251,7 @@ static void com_android_networkstack_tethering_BpfUtils_tcFilterAddDevBpf(
.nla_len = sizeof(req.kind), .nla_len = sizeof(req.kind),
.nla_type = TCA_KIND, .nla_type = TCA_KIND,
}, },
// Classifier name. See cls_bpf_ops in net/sched/cls_bpf.c. .str = CLS_BPF_KIND_NAME,
.str = "bpf",
}, },
.options = .options =
{ {