Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-28 Thread Christina Jacob
On Wed, Oct 11, 2017 at 3:07 AM, David Daney wrote: > On 10/10/2017 10:19 AM, Stephen Hemminger wrote: >> >> On Tue, 10 Oct 2017 12:58:52 +0530 >> Christina Jacob wrote: >> >>> +/* Get the mac address of the interface given interface

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-28 Thread Christina Jacob
On Wed, Oct 11, 2017 at 3:07 AM, David Daney wrote: > On 10/10/2017 10:19 AM, Stephen Hemminger wrote: >> >> On Tue, 10 Oct 2017 12:58:52 +0530 >> Christina Jacob wrote: >> >>> +/* Get the mac address of the interface given interface name */ >>> +static long *getmac(char *iface) >>> +{ >>> +

RE: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-11 Thread David Laight
From: Jesper Dangaard Brouer > Sent: 10 October 2017 20:06 ... > > + int src_ip = 0, dest_ip = 0; ... > > + key4.b8[4] = dest_ip % 0x100; > > + key4.b8[5] = (dest_ip >> 8) % 0x100; > > + key4.b8[6] = (dest_ip >> 16) % 0x100; > > +

RE: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-11 Thread David Laight
From: Jesper Dangaard Brouer > Sent: 10 October 2017 20:06 ... > > + int src_ip = 0, dest_ip = 0; ... > > + key4.b8[4] = dest_ip % 0x100; > > + key4.b8[5] = (dest_ip >> 8) % 0x100; > > + key4.b8[6] = (dest_ip >> 16) % 0x100; > > +

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread David Daney
On 10/10/2017 10:19 AM, Stephen Hemminger wrote: On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: +/* Get the mac address of the interface given interface name */ +static long *getmac(char *iface) +{ + int fd; + struct ifreq ifr; +

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread David Daney
On 10/10/2017 10:19 AM, Stephen Hemminger wrote: On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: +/* Get the mac address of the interface given interface name */ +static long *getmac(char *iface) +{ + int fd; + struct ifreq ifr; + long *mac = NULL; + + fd =

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Jesper Dangaard Brouer
On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: > +SEC("xdp3") > +int xdp_prog3(struct xdp_md *ctx) > +{ > + void *data_end = (void *)(long)ctx->data_end; > + void *data = (void *)(long)ctx->data; > + struct ethhdr *eth = data; > + int

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Jesper Dangaard Brouer
On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: > +SEC("xdp3") > +int xdp_prog3(struct xdp_md *ctx) > +{ > + void *data_end = (void *)(long)ctx->data_end; > + void *data = (void *)(long)ctx->data; > + struct ethhdr *eth = data; > + int rc = XDP_DROP, forward_to; > +

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Stephen Hemminger
On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: > + bzero(, sizeof(route)); > + bzero(dsts, sizeof(dsts)); > + bzero(dsts_len, sizeof(dsts_len)); > + bzero(gws, sizeof(gws)); > + bzero(ifs,

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Stephen Hemminger
On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: > + bzero(, sizeof(route)); > + bzero(dsts, sizeof(dsts)); > + bzero(dsts_len, sizeof(dsts_len)); > + bzero(gws, sizeof(gws)); > + bzero(ifs, sizeof(ifs)); > +

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Stephen Hemminger
On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: > +/* Get the mac address of the interface given interface name */ > +static long *getmac(char *iface) > +{ > + int fd; > + struct ifreq ifr; > + long *mac = NULL; > + > + fd =

Re: [PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Stephen Hemminger
On Tue, 10 Oct 2017 12:58:52 +0530 Christina Jacob wrote: > +/* Get the mac address of the interface given interface name */ > +static long *getmac(char *iface) > +{ > + int fd; > + struct ifreq ifr; > + long *mac = NULL; > + > + fd = socket(AF_INET, SOCK_DGRAM, 0); > +

[PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Christina Jacob
Implements port to port forwarding with route table and arp table lookup for ipv4 packets using bpf_redirect helper function and lpm_trie map. Signed-off-by: Christina Jacob --- samples/bpf/Makefile |4 + samples/bpf/xdp_router_ipv4_kern.c | 189

[PATCH v2] xdp: Sample xdp program implementing ip forward

2017-10-10 Thread Christina Jacob
Implements port to port forwarding with route table and arp table lookup for ipv4 packets using bpf_redirect helper function and lpm_trie map. Signed-off-by: Christina Jacob --- samples/bpf/Makefile |4 + samples/bpf/xdp_router_ipv4_kern.c | 189 +++