From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: <netdev@vger.kernel.org>, Alexei Starovoitov <ast@fb.com>,
Brenden Blanco <bblanco@plumgrid.com>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
Jakub Kicinski <kubakici@wp.pl>,
John Fastabend <john.fastabend@gmail.com>,
Saeed Mahameed <saeedm@mellanox.com>,
Tariq Toukan <tariqt@mellanox.com>,
Kernel Team <kernel-team@fb.com>,
brouer@redhat.com
Subject: Re: [PATCH v3 net-next 4/4] bpf: xdp: Add XDP example for head adjustment
Date: Wed, 7 Dec 2016 11:34:24 +0100 [thread overview]
Message-ID: <20161207113424.4e6fe238@redhat.com> (raw)
In-Reply-To: <1481088714-54512-5-git-send-email-kafai@fb.com>
On Tue, 6 Dec 2016 21:31:54 -0800
Martin KaFai Lau <kafai@fb.com> wrote:
> The XDP prog checks if the incoming packet matches any VIP:PORT
> combination in the BPF hashmap. If it is, it will encapsulate
> the packet with a IPv4/v6 header as instructed by the value of
> the BPF hashmap and then XDP_TX it out.
>
> The VIP:PORT -> IP-Encap-Info can be specified by the cmd args
> of the user prog.
>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
> samples/bpf/Makefile | 4 +
> samples/bpf/bpf_helpers.h | 2 +
> samples/bpf/bpf_load.c | 94 ++++++++++++++
> samples/bpf/bpf_load.h | 1 +
> samples/bpf/xdp1_user.c | 93 --------------
> samples/bpf/xdp_tx_iptnl_common.h | 37 ++++++
> samples/bpf/xdp_tx_iptnl_kern.c | 232 ++++++++++++++++++++++++++++++++++
> samples/bpf/xdp_tx_iptnl_user.c | 253 ++++++++++++++++++++++++++++++++++++++
I got confused by the file name "iptnl", I didn't realize this was
short for iptunnel, before after reading the actually XDP program code.
These are "samples" XDP programs that normal people are expected to
find/discover, could we name it "xdp_tx_tunnel" or "xdp_tx_iptunnel"?
(To guide peoples search for this)
I will likely add a "xdp_tx_vlan" example as I have a customer use-case
that needs this for DDoS scrubbing[1]
[1] http://prototype-kernel.readthedocs.io/en/latest/networking/XDP/use-cases/xdp_use_case_ddos_scrubber.html#forward-clean-traffic
[...]
> diff --git a/samples/bpf/xdp_tx_iptnl_kern.c b/samples/bpf/xdp_tx_iptnl_kern.c
> new file mode 100644
> index 000000000000..d88c064175aa
> --- /dev/null
> +++ b/samples/bpf/xdp_tx_iptnl_kern.c
> @@ -0,0 +1,232 @@
> +/* Copyright (c) 2016 Facebook
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of version 2 of the GNU General Public
> + * License as published by the Free Software Foundation.
Can we add short description of the program, to let readers know if
this is the sample they are looking for. Max 3 lines, like:
This program demonstrate how XDP does packet header adjustment, here
by adding an encapsulation tunnel header based on a BPF hashmap.
> + */
> +#include <uapi/linux/bpf.h>
> +#include <linux/in.h>
> +#include <linux/if_ether.h>
> +#include <linux/if_packet.h>
> +#include <linux/if_vlan.h>
> +#include <linux/ip.h>
> +#include <linux/ipv6.h>
> +#include "bpf_helpers.h"
> +#include "xdp_tx_iptnl_common.h"
> +
> +struct bpf_map_def SEC("maps") rxcnt = {
> + .type = BPF_MAP_TYPE_PERCPU_ARRAY,
> + .key_size = sizeof(__u32),
> + .value_size = sizeof(__u64),
> + .max_entries = 256,
> +};
> +
> +struct bpf_map_def SEC("maps") vip2tnl = {
> + .type = BPF_MAP_TYPE_HASH,
> + .key_size = sizeof(struct vip),
> + .value_size = sizeof(struct iptnl_info),
> + .max_entries = MAX_IPTNL_ENTRIES,
> +};
[...]
> diff --git a/samples/bpf/xdp_tx_iptnl_user.c b/samples/bpf/xdp_tx_iptnl_user.c
> new file mode 100644
> index 000000000000..9aeef7579af4
> --- /dev/null
> +++ b/samples/bpf/xdp_tx_iptnl_user.c
> @@ -0,0 +1,253 @@
> +/* Copyright (c) 2016 Facebook
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of version 2 of the GNU General Public
> + * License as published by the Free Software Foundation.
> + */
[...]
> +
> +static void usage(const char *cmd)
> +{
Wondering if there should be a descriptive header, that says e.g.
"XDP tunnel sample" or if command filename "xdp_tx_iptunnel" or
"xdp_tx_tunnel" would be descriptive enough.
> + printf("Usage: %s [...]\n", cmd);
> + printf(" -i <ifindex> Interface Index\n");
> + printf(" -a <vip-service-address> IPv4 or IPv6\n");
> + printf(" -p <vip-service-port> A port range (e.g. 433-444) is also allowed\n");
> + printf(" -s <source-ip> Used in the IPTunnel Header\n");
> + printf(" -d <dest-ip> Used in the IPTunnel header>\n");
> + printf(" -m <dest-MAC> Used in sending the IP Tunneled pkt>\n");
> + printf(" -T <stop-after-X-seconds> Default: 0 (forever)\n");
> + printf(" -P <IP-Protocol> Default is TCP\n");
> + printf(" -h Display this help\n");
> +}
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
prev parent reply other threads:[~2016-12-07 10:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-07 5:31 [PATCH v3 net-next 0/4]: Allow head adjustment in XDP prog Martin KaFai Lau
2016-12-07 5:31 ` [PATCH v3 net-next 1/4] bpf: xdp: " Martin KaFai Lau
2016-12-07 9:32 ` Daniel Borkmann
2016-12-07 11:41 ` Jakub Kicinski
2016-12-07 13:34 ` Daniel Borkmann
2016-12-07 16:37 ` Alexei Starovoitov
2016-12-07 17:04 ` David Miller
2016-12-07 17:14 ` Daniel Borkmann
2016-12-07 17:26 ` Martin KaFai Lau
2016-12-07 5:31 ` [PATCH v3 net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs Martin KaFai Lau
2016-12-07 5:31 ` [PATCH v3 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active Martin KaFai Lau
2016-12-07 5:31 ` [PATCH v3 net-next 4/4] bpf: xdp: Add XDP example for head adjustment Martin KaFai Lau
2016-12-07 10:34 ` Jesper Dangaard Brouer [this message]
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=20161207113424.4e6fe238@redhat.com \
--to=brouer@redhat.com \
--cc=ast@fb.com \
--cc=bblanco@plumgrid.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kernel-team@fb.com \
--cc=kubakici@wp.pl \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=tariqt@mellanox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.