Support NLM_F_REPLACE flag when sending a RTM_NEWADDR message.
NLM_F_REPLACE is helpful when we only want to update the preferred and valid lifetime for a specific IPv6 address. DHCPv6 prefix delegation gives a concrete example, once client refreshes the delegated prefix successfully in RENEW or REBIND state, it also needs to extend the preferred and valid lifetime of an IPv6 address, otherwise, it becomes depreacated when the lifetime expires. Add the NLM_F_REPLACE flag to replace the existing matching address object with updated fields. Bug: 260934173 Test: atest NetworkStaticLibsTests Change-Id: Ic001ddf9cfb031a586bbe177819e7666eaf7cde0
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.net.module.util.netlink;
|
package com.android.net.module.util.netlink;
|
||||||
|
|
||||||
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_ACK;
|
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_ACK;
|
||||||
|
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REPLACE;
|
||||||
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
|
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
|
||||||
|
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
@@ -168,7 +169,7 @@ public class RtNetlinkAddressMessage extends NetlinkMessage {
|
|||||||
|
|
||||||
final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
|
final StructNlMsgHdr nlmsghdr = new StructNlMsgHdr();
|
||||||
nlmsghdr.nlmsg_type = NetlinkConstants.RTM_NEWADDR;
|
nlmsghdr.nlmsg_type = NetlinkConstants.RTM_NEWADDR;
|
||||||
nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
|
nlmsghdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_ACK;
|
||||||
nlmsghdr.nlmsg_seq = seqNo;
|
nlmsghdr.nlmsg_seq = seqNo;
|
||||||
|
|
||||||
final RtNetlinkAddressMessage msg = new RtNetlinkAddressMessage(nlmsghdr);
|
final RtNetlinkAddressMessage msg = new RtNetlinkAddressMessage(nlmsghdr);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class RtNetlinkAddressMessageTest {
|
|||||||
// struct nlmsghdr
|
// struct nlmsghdr
|
||||||
"48000000" + // length = 72
|
"48000000" + // length = 72
|
||||||
"1400" + // type = 20 (RTM_NEWADDR)
|
"1400" + // type = 20 (RTM_NEWADDR)
|
||||||
"0500" + // flags = NLM_F_ACK | NLM_F_REQUEST
|
"0501" + // flags = NLM_F_ACK | NLM_F_REQUEST | NLM_F_REPLACE
|
||||||
"01000000" + // seqno = 1
|
"01000000" + // seqno = 1
|
||||||
"00000000" + // pid = 0 (send to kernel)
|
"00000000" + // pid = 0 (send to kernel)
|
||||||
// struct IfaddrMsg
|
// struct IfaddrMsg
|
||||||
@@ -195,7 +195,7 @@ public class RtNetlinkAddressMessageTest {
|
|||||||
// struct nlmsghdr
|
// struct nlmsghdr
|
||||||
"48000000" + // length = 72
|
"48000000" + // length = 72
|
||||||
"1400" + // type = 20 (RTM_NEWADDR)
|
"1400" + // type = 20 (RTM_NEWADDR)
|
||||||
"0500" + // flags = NLM_F_ACK | NLM_F_REQUEST
|
"0501" + // flags = NLM_F_ACK | NLM_F_REQUEST | NLM_F_REPLACE
|
||||||
"01000000" + // seqno = 1
|
"01000000" + // seqno = 1
|
||||||
"00000000" + // pid = 0 (send to kernel)
|
"00000000" + // pid = 0 (send to kernel)
|
||||||
// struct IfaddrMsg
|
// struct IfaddrMsg
|
||||||
|
|||||||
Reference in New Issue
Block a user