- error = rtm_write(cmd, &sin_dest, mask,
- gate ? &sin_gate : NULL, smplsp,
- ifindex, bh_type, metric);
-
- if (IS_ZEBRA_DEBUG_KERNEL) {
- if (!gate) {
- zlog_debug(
- "%s: %s: attention! gate not found for re",
- __func__, prefix_buf);
- } else
- inet_ntop(p->family == AFI_IP ? AF_INET
- : AF_INET6,
- &sin_gate.sin.sin_addr,
- gate_buf, INET_ADDRSTRLEN);
- }
- switch (error) {
- /* We only flag nexthops as being in FIB if
- * rtm_write() did its work. */
- case ZEBRA_ERR_NOERROR:
- nexthop_num++;
- if (IS_ZEBRA_DEBUG_KERNEL)
- zlog_debug(
- "%s: %s: successfully did NH %s",
- __func__, prefix_buf, gate_buf);
- if (cmd == RTM_ADD)
- SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
- break;
+ error = rtm_write(cmd, &sin_dest, &sin_mask,
+ gate ? &sin_gate : NULL, smplsp,
+ ifindex, bh_type, metric);
+
+ if (IS_ZEBRA_DEBUG_KERNEL) {
+ if (!gate) {
+ zlog_debug("%s: %s: attention! gate not found for re",
+ __func__, prefix_buf);
+ } else
+ inet_ntop(p->family == AFI_IP ? AF_INET
+ : AF_INET6,
+ &sin_gate.sin.sin_addr,
+ gate_buf, INET_ADDRSTRLEN);
+ }
+ switch (error) {
+ /* We only flag nexthops as being in FIB if
+ * rtm_write() did its work. */
+ case ZEBRA_ERR_NOERROR:
+ nexthop_num++;
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug("%s: %s: successfully did NH %s",
+ __func__, prefix_buf, gate_buf);
+ if (cmd == RTM_ADD)
+ SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
+ break;
+
+ /* The only valid case for this error is
+ * kernel's failure to install a multipath
+ * route, which is common for FreeBSD. This
+ * should be ignored silently, but logged as an error
+ * otherwise.
+ */
+ case ZEBRA_ERR_RTEXIST:
+ if (cmd != RTM_ADD)
+ flog_err(EC_LIB_SYSTEM_CALL,
+ "%s: rtm_write() returned %d for command %d",
+ __func__, error, cmd);
+ continue;