0

I'm trying to compile a module that uses 8021q calls. I have 8021q installed with a makefile and kconfig in /lib/modules/[version]/build/net/8021q. When I attempt to build however, I receive the following:

WARNING: "register_vlan_dev" [/home/user/test/test.ko] undefined!

I'm new to building modules, so how do I make this function visible to my module?

My code block (full of errors, but just as an example):

int create_and_register(struct gfast_dfe_entry *dfe,
                           uint16_t port_on_dfe, uint16_t tag)
{
int ret = -ENODEV;

uint16_t  portidx = (uint16_t)(0);
static char port_ifname[IFNAMSIZ] = "eth0";

static struct  net_device  *ports[10];

ports[portidx] = alloc_netdev(privsize, port_ifname, NULL);

if ((ret = register_vlan_dev(ports[portidx])) != 0) {
    PWARN("cannot create port%d - register_vlan_dev returned err=%d",
           portidx, ret);
    rtnl_unlock();
    goto err_reg_vlandev;
}
return 0;
err_reg_vlandev:
free_netdev(ports[portidx]);
ports[portidx] = NULL;
return 1;
}

My makefile:

obj-m += test.o
test-objs := main.o
KERNELPATH:=/lib/modules/$(shell uname -r)/build

all: modules

modules:
make -C $(KERNELPATH) M=$(shell pwd) -Wall modules

clean:
make -C $(KERNELPATH) M=$(shell pwd) clean

Thanks for the help!

R. Kegel
  • 3
  • 3
  • 1
    Function `register_vlan_dev` is not exported (with `EXPORT_SYMBOL`) for modules. That means, modules cannot use it. – Tsyvarev Jun 21 '16 at 20:57
  • How would I go about exporting it? Would I have to rebuild the 8021q module? – R. Kegel Jun 21 '16 at 21:01
  • 1
    You may add `EXPORT_SYMBOL()` call into the 8021q module source code, and rebuild it. But it is always preferred way to not use symbols, which are not exported: they are just not intended for using from outside of the kernel. – Tsyvarev Jun 21 '16 at 21:06

0 Answers0