From: Eddie Hao <eddieh@google.com>
To: ast@kernel.org, daniel@iogearbox.net
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Eddie Hao <eddieh@google.com>
Subject: [PATCH] bpf: allow BPF programs access skb_shared_info->gso_segs field
Date: Sun, 15 Jul 2018 01:45:24 -0700 [thread overview]
Message-ID: <20180715084524.181717-1-eddieh@google.com> (raw)
This adds the ability to read gso_segs from a BPF program. This is useful
for user space monitoring systems to get gso_segs statistics for each
arbitrary group of flows defined by the BPF program.
Signed-off-by: Eddie Hao <eddieh@google.com>
---
include/uapi/linux/bpf.h | 1 +
net/core/filter.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index b7db3261c62d..282085445616 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2266,6 +2266,7 @@ struct __sk_buff {
/* ... here. */
__u32 data_meta;
+ unsigned short gso_segs;
};
struct bpf_tunnel_key {
diff --git a/net/core/filter.c b/net/core/filter.c
index b9ec916f4e3a..f17e249f3fbb 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5820,6 +5820,15 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
bpf_target_off(struct sock_common,
skc_num, 2, target_size));
break;
+
+ case offsetof(struct __sk_buff, gso_segs):
+ BUILD_BUG_ON(FIELD_SIZEOF(struct skb_shared_info, gso_segs) !=
+ sizeof(unsigned short));
+ off = offsetof(struct sk_buff, end);
+ off += offsetof(struct skb_shared_info, gso_segs);
+ *insn++ = BPF_LDX_MEM(BPF_SIZEOF(unsigned short), si->dst_reg,
+ si->src_reg, off);
+ break;
}
return insn - insn_buf;
--
2.18.0.203.gfac676dfb9-goog
next reply other threads:[~2018-07-15 8:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-15 8:45 Eddie Hao [this message]
2018-07-15 22:06 ` [PATCH] bpf: allow BPF programs access skb_shared_info->gso_segs field Eddie Hao
2018-07-16 22:30 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180715084524.181717-1-eddieh@google.com \
--to=eddieh@google.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).