From: Roy Marples Date: Tue, 5 Jan 2016 17:09:37 +0000 (+0000) Subject: Set route/netlink seq number correctly. X-Git-Tag: v6.10.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98bdb382077a380bfcb9a60950cacdd01776100c;p=thirdparty%2Fdhcpcd.git Set route/netlink seq number correctly. --- diff --git a/dhcpcd.h b/dhcpcd.h index d198e654..947afe13 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -121,6 +121,7 @@ struct dhcpcd_ctx { int pf_link_fd; #endif int link_fd; + int seq; /* route message sequence no */ #ifdef USE_SIGNALS sigset_t sigset; diff --git a/if-bsd.c b/if-bsd.c index 9607faad..db173805 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -556,11 +556,11 @@ if_route(unsigned char cmd, const struct rt *rt) memset(&rtm, 0, sizeof(rtm)); rtm.hdr.rtm_version = RTM_VERSION; - rtm.hdr.rtm_seq = 1; rtm.hdr.rtm_type = cmd; rtm.hdr.rtm_addrs = RTA_DST; rtm.hdr.rtm_flags = RTF_UP; rtm.hdr.rtm_pid = getpid(); + rtm.hdr.rtm_seq = ++rt->iface->ctx->seq; #ifdef RTF_PINNED if (cmd != RTM_ADD) rtm.hdr.rtm_flags |= RTF_PINNED; @@ -944,10 +944,10 @@ if_route6(unsigned char cmd, const struct rt6 *rt) memset(&rtm, 0, sizeof(rtm)); rtm.hdr.rtm_version = RTM_VERSION; - rtm.hdr.rtm_seq = 1; rtm.hdr.rtm_type = cmd; rtm.hdr.rtm_flags = RTF_UP | (int)rt->flags; rtm.hdr.rtm_pid = getpid(); + rtm.hdr.rtm_seq = ++rt->iface->ctx->seq; #ifdef RTF_PINNED if (rtm.hdr.rtm_type != RTM_ADD) rtm.hdr.rtm_flags |= RTF_PINNED; diff --git a/if-linux.c b/if-linux.c index 255ee207..b78f1800 100644 --- a/if-linux.c +++ b/if-linux.c @@ -870,7 +870,6 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, struct sockaddr_nl snl; struct iovec iov; struct msghdr msg; - static unsigned int seq; memset(&snl, 0, sizeof(snl)); if ((s = _open_link_socket(&snl, protocol)) == -1) @@ -885,7 +884,7 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, msg.msg_iovlen = 1; /* Request a reply */ hdr->nlmsg_flags |= NLM_F_ACK; - hdr->nlmsg_seq = ++seq; + hdr->nlmsg_seq = ++ctx->seq; if (sendmsg(s, &msg, 0) != -1) r = get_netlink(ctx, ifp, s, 0, callback);