Re: [PATCHv6 bpf-next] samples/bpf: add xdp program on egress for xdp_redirect_map

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Yonghong,
On Thu, Jan 14, 2021 at 01:01:28PM -0800, Yonghong Song wrote:
> > +/* map to stroe egress interface mac address */
> 
> s/stroe/store

Thanks, I will fix it.
> > -	struct bpf_program *prog, *dummy_prog;
> > +	struct bpf_program *prog, *dummy_prog, *devmap_prog;
> > +	int devmap_prog_fd_0 = -1, devmap_prog_fd_1 = -1;
> 
> The default value is -1 here. I remembered there was a discussion
> about the default value here, does default value 0 work here?

I didn't saw the discussion. But 0 should works as in __dev_map_alloc_node
it only gets the prog when fd > 0.

static struct bpf_dtab_netdev *__dev_map_alloc_node(struct net *net,
                                                    struct bpf_dtab *dtab,
                                                    struct bpf_devmap_val *val,
                                                    unsigned int idx)
{
	...
	if (val->bpf_prog.fd > 0) {
		prog = bpf_prog_get_type_dev(val->bpf_prog.fd,
				BPF_PROG_TYPE_XDP, false);
		if (IS_ERR(prog))
			goto err_put_dev;
		if (prog->expected_attach_type != BPF_XDP_DEVMAP)
			goto err_put_prog;
	}
	...
}

> > +	if (xdp_flags & XDP_FLAGS_SKB_MODE) {
> > +		prog = bpf_object__find_program_by_title(obj, "xdp_redirect_general");
> 
> libbpf supports each section having multiple programs, so
> bpf_object__find_program_by_title() is not recommended.
> Could you change to bpf_object__find_program_by_name()?

Thanks for this reminder, I will fix it.

Thanks
Hangbin



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux