aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2015-04-01 20:12:13 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-06 16:42:35 -0400
commit91bc4822c3d61b9bb7ef66d3b77948a4f9177954 (patch)
treeca92a811b501957c1e876290d305aaf81c8d9aff /include/uapi
parent5888b93b750609680735d6b8b737703083ef40ff (diff)
tc: bpf: add checksum helpers
Commit 608cd71a9c7c ("tc: bpf: generalize pedit action") has added the possibility to mangle packet data to BPF programs in the tc pipeline. This patch adds two helpers bpf_l3_csum_replace() and bpf_l4_csum_replace() for fixing up the protocol checksums after the packet mangling. It also adds 'flags' argument to bpf_skb_store_bytes() helper to avoid unnecessary checksum recomputations when BPF programs adjusting l3/l4 checksums and documents all three helpers in uapi header. Moreover, a sample program is added to show how BPF programs can make use of the mangle and csum helpers. Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi')
-rw-r--r--include/uapi/linux/bpf.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 0db8580f3cca..23df3e7f8e7d 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -168,7 +168,43 @@ enum bpf_func_id {
168 BPF_FUNC_map_delete_elem, /* int map_delete_elem(&map, &key) */ 168 BPF_FUNC_map_delete_elem, /* int map_delete_elem(&map, &key) */
169 BPF_FUNC_get_prandom_u32, /* u32 prandom_u32(void) */ 169 BPF_FUNC_get_prandom_u32, /* u32 prandom_u32(void) */
170 BPF_FUNC_get_smp_processor_id, /* u32 raw_smp_processor_id(void) */ 170 BPF_FUNC_get_smp_processor_id, /* u32 raw_smp_processor_id(void) */
171 BPF_FUNC_skb_store_bytes, /* int skb_store_bytes(skb, offset, from, len) */ 171
172 /**
173 * skb_store_bytes(skb, offset, from, len, flags) - store bytes into packet
174 * @skb: pointer to skb
175 * @offset: offset within packet from skb->data
176 * @from: pointer where to copy bytes from
177 * @len: number of bytes to store into packet
178 * @flags: bit 0 - if true, recompute skb->csum
179 * other bits - reserved
180 * Return: 0 on success
181 */
182 BPF_FUNC_skb_store_bytes,
183
184 /**
185 * l3_csum_replace(skb, offset, from, to, flags) - recompute IP checksum
186 * @skb: pointer to skb
187 * @offset: offset within packet where IP checksum is located
188 * @from: old value of header field
189 * @to: new value of header field
190 * @flags: bits 0-3 - size of header field
191 * other bits - reserved
192 * Return: 0 on success
193 */
194 BPF_FUNC_l3_csum_replace,
195
196 /**
197 * l4_csum_replace(skb, offset, from, to, flags) - recompute TCP/UDP checksum
198 * @skb: pointer to skb
199 * @offset: offset within packet where TCP/UDP checksum is located
200 * @from: old value of header field
201 * @to: new value of header field
202 * @flags: bits 0-3 - size of header field
203 * bit 4 - is pseudo header
204 * other bits - reserved
205 * Return: 0 on success
206 */
207 BPF_FUNC_l4_csum_replace,
172 __BPF_FUNC_MAX_ID, 208 __BPF_FUNC_MAX_ID,
173}; 209};
174 210