mirror of https://github.com/F-Stack/f-stack.git
Add support to set interface name of each port in `config.ini`.
This commit is contained in:
parent
e7dcc16ebb
commit
5c84990d9f
|
@ -84,6 +84,8 @@ addr=192.168.1.2
|
||||||
netmask=255.255.225.0
|
netmask=255.255.225.0
|
||||||
broadcast=192.168.1.255
|
broadcast=192.168.1.255
|
||||||
gateway=192.168.1.1
|
gateway=192.168.1.1
|
||||||
|
# set interface name, Optional parameter.
|
||||||
|
#if_name=eno7
|
||||||
|
|
||||||
# IPv6 net addr, Optional parameters.
|
# IPv6 net addr, Optional parameters.
|
||||||
#addr6=ff::02
|
#addr6=ff::02
|
||||||
|
|
|
@ -489,7 +489,9 @@ port_cfg_handler(struct ff_config *cfg, const char *section,
|
||||||
cur->port_id = portid;
|
cur->port_id = portid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(name, "addr") == 0) {
|
if (strcmp(name, "ifc_name") == 0) {
|
||||||
|
cur->ifname = strdup(value);
|
||||||
|
} else if (strcmp(name, "addr") == 0) {
|
||||||
cur->addr = strdup(value);
|
cur->addr = strdup(value);
|
||||||
} else if (strcmp(name, "netmask") == 0) {
|
} else if (strcmp(name, "netmask") == 0) {
|
||||||
cur->netmask = strdup(value);
|
cur->netmask = strdup(value);
|
||||||
|
|
|
@ -56,6 +56,7 @@ struct ff_hw_features {
|
||||||
|
|
||||||
struct ff_port_cfg {
|
struct ff_port_cfg {
|
||||||
char *name;
|
char *name;
|
||||||
|
char *ifname;
|
||||||
uint8_t port_id;
|
uint8_t port_id;
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
struct ff_hw_features hw_features;
|
struct ff_hw_features hw_features;
|
||||||
|
|
|
@ -617,7 +617,11 @@ ff_veth_attach(struct ff_port_cfg *cfg)
|
||||||
}
|
}
|
||||||
memset(sc, 0, sizeof(struct ff_veth_softc));
|
memset(sc, 0, sizeof(struct ff_veth_softc));
|
||||||
|
|
||||||
snprintf(sc->host_ifname, sizeof(sc->host_ifname), ff_IF_NAME, cfg->port_id);
|
if(cfg->ifname){
|
||||||
|
snprintf(sc->host_ifname, sizeof(sc->host_ifname), "%s", cfg->ifname);
|
||||||
|
} else {
|
||||||
|
snprintf(sc->host_ifname, sizeof(sc->host_ifname), ff_IF_NAME, cfg->port_id);
|
||||||
|
}
|
||||||
|
|
||||||
error = ff_veth_config(sc, cfg);
|
error = ff_veth_config(sc, cfg);
|
||||||
if (0 != error) {
|
if (0 != error) {
|
||||||
|
|
Loading…
Reference in New Issue