.can_set_mac = ipvlan_can_set_mac,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
+ .keep_existing = true,
};
const NetDevVTable ipvtap_vtable = {
.can_set_mac = ipvlan_can_set_mac,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
+ .keep_existing = true,
};
IPVlanMode link_get_ipvlan_mode(Link *link) {
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
+ .keep_existing = true,
};
const NetDevVTable macvlan_vtable = {
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
+ .keep_existing = true,
};
assert(netdev);
assert(netdev->ifname);
- if (netdev->state != NETDEV_STATE_CREATING)
+ if (!IN_SET(netdev->state, NETDEV_STATE_LOADING, NETDEV_STATE_CREATING))
return 0;
netdev->state = NETDEV_STATE_READY;
if (!netdev_is_managed(netdev))
goto cancelled; /* Already detached, due to e.g. reloading .netdev files, cancelling the request. */
+ if (NETDEV_VTABLE(netdev)->keep_existing && netdev->ifindex > 0) {
+ /* Already exists, and the netdev does not support updating, entering the ready state. */
+ r = netdev_enter_ready(netdev);
+ if (r < 0)
+ return r;
+
+ goto cancelled;
+ }
+
r = netdev_is_ready_to_create(netdev, link);
if (r <= 0)
return r;
if (!netdev_is_managed(netdev))
return 1; /* Already detached, due to e.g. reloading .netdev files, cancelling the request. */
+ if (NETDEV_VTABLE(netdev)->keep_existing && netdev->ifindex > 0) {
+ /* Already exists, and the netdev does not support updating, entering the ready state. */
+ r = netdev_enter_ready(netdev);
+ if (r < 0)
+ return r;
+
+ return 1; /* Skip this request. */
+ }
+
r = netdev_is_ready_to_create(netdev, NULL);
if (r <= 0)
return r;
/* When assigning ifindex to the netdev, skip to check if the netdev kind matches. */
bool skip_netdev_kind_check;
+
+ /* Provides if the netdev can be updated, that is, whether RTM_NEWLINK with existing ifindex is supported or not.
+ * If this is true, the netdev does not support updating. */
+ bool keep_existing;
} NetDevVTable;
extern const NetDevVTable * const netdev_vtable[_NETDEV_KIND_MAX];