#include <unistd.h>
#include "networkd.h"
+#include "networkd-netdev.h"
#include "libudev-private.h"
#include "udev-util.h"
#include "util.h"
static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
_cleanup_link_unref_ Link *link = NULL;
uint16_t type;
- char *ifname;
+ const char *ifname;
int r, ifindex;
assert(manager);
static int link_set_dhcp_routes(Link *link) {
struct sd_dhcp_route *static_routes;
- size_t static_routes_size;
- int r;
- unsigned i;
+ int r, n, i;
assert(link);
- r = sd_dhcp_lease_get_routes(link->dhcp_lease, &static_routes, &static_routes_size);
- if (r < 0) {
- if (r != -ENOENT)
- log_warning_link(link, "DHCP error: could not get routes: %s", strerror(-r));
- return r;
+ n = sd_dhcp_lease_get_routes(link->dhcp_lease, &static_routes);
+ if (n < 0) {
+ if (n != -ENOENT)
+ log_warning_link(link, "DHCP error: could not get routes: %s", strerror(-n));
+ return n;
}
- for (i = 0; i < static_routes_size; i++) {
+ for (i = 0; i < n; i++) {
_cleanup_route_free_ Route *route = NULL;
r = route_new_dynamic(&route);
struct in_addr netmask;
struct in_addr gateway;
unsigned prefixlen;
- unsigned i;
int r;
assert(link);
if (link->network->dhcp_routes) {
struct sd_dhcp_route *routes;
- size_t routes_size;
+ int n, i;
- r = sd_dhcp_lease_get_routes(link->dhcp_lease, &routes, &routes_size);
- if (r >= 0) {
- for (i = 0; i < routes_size; i++) {
+ n = sd_dhcp_lease_get_routes(link->dhcp_lease, &routes);
+ if (n >= 0) {
+ for (i = 0; i < n; i++) {
_cleanup_route_free_ Route *route = NULL;
r = route_new_dynamic(&route);
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
- NETDEV(link->network->bond),
+ NETDEVIF(link->network->bond),
NULL);
r = netdev_join(link->network->bond, link, &netdev_join_handler);
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bond->ifname, strerror(-r),
- NETDEV(link->network->bond),
+ NETDEVIF(link->network->bond),
NULL);
link_enter_failed(link);
return r;
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
- NETDEV(link->network->bridge),
+ NETDEVIF(link->network->bridge),
NULL);
r = netdev_join(link->network->bridge, link, &netdev_join_handler);
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname, strerror(-r),
- NETDEV(link->network->bridge),
+ NETDEVIF(link->network->bridge),
NULL);
link_enter_failed(link);
return r;
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->tunnel->ifname,
- NETDEV(link->network->tunnel),
+ NETDEVIF(link->network->tunnel),
NULL);
r = netdev_join(link->network->tunnel, link, &netdev_join_handler);
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->tunnel->ifname, strerror(-r),
- NETDEV(link->network->tunnel),
+ NETDEVIF(link->network->tunnel),
NULL);
link_enter_failed(link);
return r;
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
- link->ifname, vlan->ifname, NETDEV(vlan), NULL);
+ link->ifname, vlan->ifname, NETDEVIF(vlan), NULL);
r = netdev_join(vlan, link, &netdev_join_handler);
if (r < 0) {
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, vlan->ifname, strerror(-r),
- NETDEV(vlan), NULL);
+ NETDEVIF(vlan), NULL);
link_enter_failed(link);
return r;
}
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
- link->ifname, macvlan->ifname, NETDEV(macvlan), NULL);
+ link->ifname, macvlan->ifname, NETDEVIF(macvlan), NULL);
r = netdev_join(macvlan, link, &netdev_join_handler);
if (r < 0) {
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, macvlan->ifname, strerror(-r),
- NETDEV(macvlan), NULL);
+ NETDEVIF(macvlan), NULL);
link_enter_failed(link);
return r;
}
log_struct_link(LOG_DEBUG, link,
"MESSAGE=%*s: enslaving by '%s'",
IFNAMSIZ,
- link->ifname, vxlan->ifname, NETDEV(vxlan), NULL);
+ link->ifname, vxlan->ifname, NETDEVIF(vxlan), NULL);
r = netdev_join(vxlan, link, &netdev_join_handler);
if (r < 0) {
"MESSAGE=%*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, vxlan->ifname, strerror(-r),
- NETDEV(vxlan), NULL);
+ NETDEVIF(vxlan), NULL);
link_enter_failed(link);
return r;
}
if (r < 0)
return r;
+ r = sd_dhcp_client_set_request_broadcast(link->dhcp_client, link->network->dhcp_broadcast);
+ if (r < 0)
+ return r;
+
if (link->network->dhcp_mtu) {
r = sd_dhcp_client_set_request_option(link->dhcp_client, 26);
if (r < 0)
if (link->state != LINK_STATE_INITIALIZING)
return 0;
+ if (link->udev_device)
+ return 0;
+
log_debug_link(link, "udev initialized link");
link->udev_device = udev_device_ref(device);
int link_update(Link *link, sd_rtnl_message *m) {
struct ether_addr mac;
- char *ifname;
+ const char *ifname;
int r;
assert(link);
fprintf(f,
"# This is private data. Do not parse.\n"
"ADMIN_STATE=%s\n"
- "OPER_STATE=%s\n"
- "FLAGS=%u\n",
- admin_state, oper_state, link->flags);
+ "OPER_STATE=%s\n",
+ admin_state, oper_state);
if (link->network) {
serialize_addresses(f, "DNS", link->network->dns);