| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include <linux/if_arp.h> |
| 4 |
|
| 5 |
#include "sd-netlink.h" |
| 6 |
|
| 7 |
#include "networkd-route-util.h" |
| 8 |
#include "vrf.h" |
| 9 |
|
| 10 |
int config_parse_vrf_table( |
| 11 |
const char *unit, |
| 12 |
const char *filename, |
| 13 |
unsigned line, |
| 14 |
const char *section, |
| 15 |
unsigned section_line, |
| 16 |
const char *lvalue, |
| 17 |
int ltype, |
| 18 |
const char *rvalue, |
| 19 |
void *data, |
| 20 |
void *userdata) { |
| 21 |
|
| 22 |
Vrf *vrf = ASSERT_PTR(userdata); |
| 23 |
uint32_t *table = ASSERT_PTR(data); |
| 24 |
int r; |
| 25 |
|
| 26 |
assert(filename); |
| 27 |
assert(lvalue); |
| 28 |
assert(rvalue); |
| 29 |
|
| 30 |
r = manager_get_route_table_from_string(vrf->meta.manager, rvalue, table); |
| 31 |
if (r < 0) { |
| 32 |
log_syntax(unit, LOG_WARNING, filename, line, r, |
| 33 |
"Failed to parse %s=, ignoring assignment: %s", |
| 34 |
lvalue, rvalue); |
| 35 |
return 0; |
| 36 |
} |
| 37 |
|
| 38 |
return 0; |
| 39 |
} |
| 40 |
|
| 41 |
static int netdev_vrf_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) { |
| 42 |
assert(!link); |
| 43 |
assert(m); |
| 44 |
|
| 45 |
Vrf *v = VRF(netdev); |
| 46 |
int r; |
| 47 |
|
| 48 |
r = sd_netlink_message_append_u32(m, IFLA_VRF_TABLE, v->table); |
| 49 |
if (r < 0) |
| 50 |
return r; |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |
| 54 |
|
| 55 |
static bool vrf_can_set_mac(NetDev *netdev, const struct hw_addr_data *hw_addr) { |
| 56 |
return true; |
| 57 |
} |
| 58 |
|
| 59 |
const NetDevVTable vrf_vtable = { |
| 60 |
.object_size = sizeof(Vrf), |
| 61 |
.sections = NETDEV_COMMON_SECTIONS "VRF\0", |
| 62 |
.fill_message_create = netdev_vrf_fill_message_create, |
| 63 |
.create_type = NETDEV_CREATE_INDEPENDENT, |
| 64 |
.can_set_mac = vrf_can_set_mac, |
| 65 |
.iftype = ARPHRD_ETHER, |
| 66 |
.generate_mac = true, |
| 67 |
.keep_existing = true, |
| 68 |
}; |