+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
"/etc/systemd/network",
"/run/systemd/network",
"/usr/lib/systemd/network",
-#ifdef HAVE_SPLIT_USR
+#if HAVE_SPLIT_USR
"/lib/systemd/network",
#endif
NULL};
if (r < 0) {
log_warning_errno(r, "rtnl: could not get message type: %m");
return 0;
- } else if (type != RTM_NEWROUTE && type != RTM_DELROUTE) {
+ } else if (!IN_SET(type, RTM_NEWROUTE, RTM_DELROUTE)) {
log_warning("rtnl: received unexpected message type when processing route");
return 0;
}
break;
default:
- log_link_debug(link, "rtnl: ignoring unsupported address family: %d", family);
+ assert_not_reached("Received unsupported address family");
return 0;
}
if (r < 0) {
log_warning_errno(r, "rtnl: could not get message type: %m");
return 0;
- } else if (type != RTM_NEWADDR && type != RTM_DELADDR) {
+ } else if (!IN_SET(type, RTM_NEWADDR, RTM_DELADDR)) {
log_warning("rtnl: received unexpected message type when processing address");
return 0;
}
if (r < 0) {
log_warning_errno(r, "rtnl: Could not get message type: %m");
return 0;
- } else if (type != RTM_NEWLINK && type != RTM_DELLINK) {
+ } else if (!IN_SET(type, RTM_NEWLINK, RTM_DELLINK)) {
log_warning("rtnl: Received unexpected message type when processing link");
return 0;
}
}
r = sd_rtnl_message_get_family(message, &family);
- if (r < 0 || !IN_SET(family, AF_INET, AF_INET6)) {
- log_warning_errno(r, "rtnl: received address with invalid family type %u, ignoring.", type);
+ if (r < 0) {
+ log_warning_errno(r, "rtnl: could not get rule family: %m");
+ return 0;
+ } else if (!IN_SET(family, AF_INET, AF_INET6)) {
+ log_debug("rtnl: received address with invalid family %u, ignoring.", family);
return 0;
}
break;
default:
- log_debug("rtnl: ignoring unsupported rule family: %d", family);
+ assert_not_reached("Received unsupported address family");
}
if (from_prefixlen == 0 && to_prefixlen == 0)
goto fail;
}
- fprintf(f, "from=%s%s/%hhu to=%s%s/%hhu tos=%hhu fwmark=%"PRIu32"/%"PRIu32" table=%hhu", space ? " " : "", from_str,
- rule->from_prefixlen, space ? " " : "", to_str, rule->to_prefixlen, rule->tos, rule->fwmark, rule->fwmask, rule->table);
+ fprintf(f, "from=%s%s/%hhu to=%s%s/%hhu tos=%hhu fwmark=%"PRIu32"/%"PRIu32" table=%"PRIu32,
+ space ? " " : "", from_str, rule->from_prefixlen,
+ space ? " " : "", to_str, rule->to_prefixlen,
+ rule->tos,
+ rule->fwmark, rule->fwmask,
+ rule->table);
fputc('\n', f);
}
return r;
r = sd_netlink_call(m->rtnl, req, 0, &reply);
- if (r < 0)
+ if (r < 0) {
+ if (r == -EOPNOTSUPP) {
+ log_debug("FIB Rules are not supported by the kernel. Ignoring.");
+ return 0;
+ }
+
return r;
+ }
for (rule = reply; rule; rule = sd_netlink_message_next(rule)) {
int k;