/* link may be NULL */
- if (in_addr_is_set(route->gw_family, &route->gw)) {
+ if (in_addr_is_set(route->gw_family, &route->gw) && route->nexthop_id == 0) {
if (route->gw_family == route->family) {
r = netlink_message_append_in_addr_union(req, RTA_GATEWAY, route->gw_family, &route->gw);
if (r < 0)
Route **ret) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
- int r, k = 0;
Route *nr;
+ int r, k;
assert(link);
assert(link->manager);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_METRICS attribute: %m");
- r = append_nexthops(route, req);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not append RTA_MULTIPATH attribute: %m");
-
- if (ordered_set_isempty(route->multipath_routes)) {
+ if (route->nexthop_id != 0 ||
+ in_addr_is_set(route->gw_family, &route->gw) ||
+ ordered_set_isempty(route->multipath_routes)) {
k = route_add_and_setup_timer(link, route, NULL, &nr);
if (k < 0)
return k;
} else {
MultipathRoute *m;
+ r = append_nexthops(route, req);
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not append RTA_MULTIPATH attribute: %m");
+
assert(!ret);
+ k = 0;
ORDERED_SET_FOREACH(m, route->multipath_routes) {
r = route_add_and_setup_timer(link, route, m, NULL);
if (r < 0)
route->section->filename, route->section->line);
}
+ if ((route->gateway_from_dhcp_or_ra ||
+ in_addr_is_set(route->gw_family, &route->gw)) &&
+ !ordered_set_isempty(route->multipath_routes))
+ return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
+ "%s: Gateway= cannot be specified with MultiPathRoute=. "
+ "Ignoring [Route] section from line %u.",
+ route->section->filename, route->section->line);
+
if (route->nexthop_id > 0 &&
- (in_addr_is_set(route->gw_family, &route->gw) ||
+ (route->gateway_from_dhcp_or_ra ||
+ in_addr_is_set(route->gw_family, &route->gw) ||
!ordered_set_isempty(route->multipath_routes)))
return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
"%s: NextHopId= cannot be specified with Gateway= or MultiPathRoute=. "