platform: add flags argument to nm_platform_ip4_address_add()
The argument is still always unset. We will need it later to set IFA_F_NOPREFIXROUTE.
This commit is contained in:
@@ -80,7 +80,7 @@ test_arping_common (test_fixture *fixture, TestInfo *info)
|
|||||||
|
|
||||||
for (i = 0; info->peer_addresses[i]; i++) {
|
for (i = 0; info->peer_addresses[i]; i++) {
|
||||||
nmtstp_ip4_address_add (FALSE, fixture->ifindex1, info->peer_addresses[i],
|
nmtstp_ip4_address_add (FALSE, fixture->ifindex1, info->peer_addresses[i],
|
||||||
24, 0, 3600, 1800, NULL);
|
24, 0, 3600, 1800, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
@@ -890,6 +890,7 @@ ip4_address_add (NMPlatform *platform,
|
|||||||
in_addr_t peer_addr,
|
in_addr_t peer_addr,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
|
guint32 flags,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||||
@@ -905,6 +906,7 @@ ip4_address_add (NMPlatform *platform,
|
|||||||
address.timestamp = nm_utils_get_monotonic_timestamp_s ();
|
address.timestamp = nm_utils_get_monotonic_timestamp_s ();
|
||||||
address.lifetime = lifetime;
|
address.lifetime = lifetime;
|
||||||
address.preferred = preferred;
|
address.preferred = preferred;
|
||||||
|
address.n_ifa_flags = flags;
|
||||||
if (label)
|
if (label)
|
||||||
g_strlcpy (address.label, label, sizeof (address.label));
|
g_strlcpy (address.label, label, sizeof (address.label));
|
||||||
|
|
||||||
|
@@ -2223,7 +2223,7 @@ _nl_msg_new_address (int nlmsg_type,
|
|||||||
NLA_PUT (msg, IFA_CACHEINFO, sizeof(ca), &ca);
|
NLA_PUT (msg, IFA_CACHEINFO, sizeof(ca), &ca);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & ~0xFF) {
|
if (flags & ~((guint32) 0xFF)) {
|
||||||
/* only set the IFA_FLAGS attribute, if they actually contain additional
|
/* only set the IFA_FLAGS attribute, if they actually contain additional
|
||||||
* flags that are not already set to am.ifa_flags.
|
* flags that are not already set to am.ifa_flags.
|
||||||
*
|
*
|
||||||
@@ -5182,6 +5182,7 @@ ip4_address_add (NMPlatform *platform,
|
|||||||
in_addr_t peer_addr,
|
in_addr_t peer_addr,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
|
guint32 flags,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
NMPObject obj_id;
|
NMPObject obj_id;
|
||||||
@@ -5194,7 +5195,7 @@ ip4_address_add (NMPlatform *platform,
|
|||||||
&addr,
|
&addr,
|
||||||
plen,
|
plen,
|
||||||
&peer_addr,
|
&peer_addr,
|
||||||
0,
|
flags,
|
||||||
nmp_utils_ip4_address_is_link_local (addr) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE,
|
nmp_utils_ip4_address_is_link_local (addr) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE,
|
||||||
lifetime,
|
lifetime,
|
||||||
preferred,
|
preferred,
|
||||||
|
@@ -2453,6 +2453,7 @@ nm_platform_ip4_address_add (NMPlatform *self,
|
|||||||
in_addr_t peer_address,
|
in_addr_t peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
|
guint32 flags,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
_CHECK_SELF (self, klass, FALSE);
|
_CHECK_SELF (self, klass, FALSE);
|
||||||
@@ -2473,12 +2474,13 @@ nm_platform_ip4_address_add (NMPlatform *self,
|
|||||||
addr.timestamp = 0; /* set it at zero, which to_string will treat as *now* */
|
addr.timestamp = 0; /* set it at zero, which to_string will treat as *now* */
|
||||||
addr.lifetime = lifetime;
|
addr.lifetime = lifetime;
|
||||||
addr.preferred = preferred;
|
addr.preferred = preferred;
|
||||||
|
addr.n_ifa_flags = flags;
|
||||||
if (label)
|
if (label)
|
||||||
g_strlcpy (addr.label, label, sizeof (addr.label));
|
g_strlcpy (addr.label, label, sizeof (addr.label));
|
||||||
|
|
||||||
_LOGD ("address: adding or updating IPv4 address: %s", nm_platform_ip4_address_to_string (&addr, NULL, 0));
|
_LOGD ("address: adding or updating IPv4 address: %s", nm_platform_ip4_address_to_string (&addr, NULL, 0));
|
||||||
}
|
}
|
||||||
return klass->ip4_address_add (self, ifindex, address, plen, peer_address, lifetime, preferred, label);
|
return klass->ip4_address_add (self, ifindex, address, plen, peer_address, lifetime, preferred, flags, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@@ -2667,7 +2669,9 @@ nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known
|
|||||||
now, ADDRESS_LIFETIME_PADDING, &lifetime, &preferred))
|
now, ADDRESS_LIFETIME_PADDING, &lifetime, &preferred))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->plen, known_address->peer_address, lifetime, preferred, known_address->label))
|
if (!nm_platform_ip4_address_add (self, ifindex, known_address->address, known_address->plen,
|
||||||
|
known_address->peer_address, lifetime, preferred,
|
||||||
|
0, known_address->label))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (out_added_addresses) {
|
if (out_added_addresses) {
|
||||||
|
@@ -591,6 +591,7 @@ typedef struct {
|
|||||||
in_addr_t peer_address,
|
in_addr_t peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred_lft,
|
guint32 preferred_lft,
|
||||||
|
guint32 flags,
|
||||||
const char *label);
|
const char *label);
|
||||||
gboolean (*ip6_address_add) (NMPlatform *,
|
gboolean (*ip6_address_add) (NMPlatform *,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
@@ -858,6 +859,7 @@ gboolean nm_platform_ip4_address_add (NMPlatform *self,
|
|||||||
in_addr_t peer_address,
|
in_addr_t peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred_lft,
|
guint32 preferred_lft,
|
||||||
|
guint32 flags,
|
||||||
const char *label);
|
const char *label);
|
||||||
gboolean nm_platform_ip6_address_add (NMPlatform *self,
|
gboolean nm_platform_ip6_address_add (NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
|
@@ -94,12 +94,12 @@ test_ip4_address_general (void)
|
|||||||
|
|
||||||
/* Add address */
|
/* Add address */
|
||||||
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime, preferred, NULL);
|
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime, preferred, 0, NULL);
|
||||||
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
||||||
accept_signal (address_added);
|
accept_signal (address_added);
|
||||||
|
|
||||||
/* Add address again (aka update) */
|
/* Add address again (aka update) */
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime + 100, preferred + 50, NULL);
|
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime + 100, preferred + 50, 0, NULL);
|
||||||
accept_signals (address_changed, 0, 1);
|
accept_signals (address_changed, 0, 1);
|
||||||
|
|
||||||
/* Test address listing */
|
/* Test address listing */
|
||||||
@@ -197,7 +197,7 @@ test_ip4_address_general_2 (void)
|
|||||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, DEVICE_IFINDEX, NULL));
|
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, DEVICE_IFINDEX, NULL));
|
||||||
|
|
||||||
/* Add/delete notification */
|
/* Add/delete notification */
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime, preferred, NULL);
|
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime, preferred, 0, NULL);
|
||||||
accept_signal (address_added);
|
accept_signal (address_added);
|
||||||
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
||||||
nmtstp_ip4_address_del (EX, ifindex, addr, IP4_PLEN, addr);
|
nmtstp_ip4_address_del (EX, ifindex, addr, IP4_PLEN, addr);
|
||||||
@@ -205,7 +205,7 @@ test_ip4_address_general_2 (void)
|
|||||||
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
||||||
|
|
||||||
/* Add/delete conflict */
|
/* Add/delete conflict */
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime, preferred, NULL);
|
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr, lifetime, preferred, 0, NULL);
|
||||||
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr));
|
||||||
accept_signal (address_added);
|
accept_signal (address_added);
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ test_ip4_address_peer (void)
|
|||||||
accept_signals (address_added, 0, G_MAXINT);
|
accept_signals (address_added, 0, G_MAXINT);
|
||||||
|
|
||||||
/* Add/delete notification */
|
/* Add/delete notification */
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr_peer, lifetime, preferred, NULL);
|
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr_peer, lifetime, preferred, 0, NULL);
|
||||||
accept_signal (address_added);
|
accept_signal (address_added);
|
||||||
a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer);
|
a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer);
|
||||||
g_assert (a);
|
g_assert (a);
|
||||||
@@ -281,7 +281,7 @@ test_ip4_address_peer (void)
|
|||||||
|
|
||||||
nmtstp_ip_address_assert_lifetime ((NMPlatformIPAddress *) a, -1, lifetime, preferred);
|
nmtstp_ip_address_assert_lifetime ((NMPlatformIPAddress *) a, -1, lifetime, preferred);
|
||||||
|
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr_peer2, lifetime, preferred, NULL);
|
nmtstp_ip4_address_add (EX, ifindex, addr, IP4_PLEN, addr_peer2, lifetime, preferred, 0, NULL);
|
||||||
accept_signal (address_added);
|
accept_signal (address_added);
|
||||||
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer));
|
g_assert (nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer));
|
||||||
a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer2);
|
a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer2);
|
||||||
@@ -328,7 +328,7 @@ test_ip4_address_peer_zero (void)
|
|||||||
for (i = 0; i < G_N_ELEMENTS (peers); i++) {
|
for (i = 0; i < G_N_ELEMENTS (peers); i++) {
|
||||||
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, plen, r_peers[i]));
|
g_assert (!nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, plen, r_peers[i]));
|
||||||
|
|
||||||
nmtstp_ip4_address_add (EX, ifindex, addr, plen, r_peers[i], lifetime, preferred, label);
|
nmtstp_ip4_address_add (EX, ifindex, addr, plen, r_peers[i], lifetime, preferred, 0, label);
|
||||||
|
|
||||||
addrs = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
addrs = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
g_assert (addrs);
|
g_assert (addrs);
|
||||||
|
@@ -63,7 +63,7 @@ test_cleanup_internal (void)
|
|||||||
g_assert (ifindex > 0);
|
g_assert (ifindex > 0);
|
||||||
|
|
||||||
/* Add routes and addresses */
|
/* Add routes and addresses */
|
||||||
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, plen4, addr4, lifetime, preferred, NULL));
|
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, plen4, addr4, lifetime, preferred, 0, NULL));
|
||||||
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, plen6, in6addr_any, lifetime, preferred, flags));
|
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, plen6, in6addr_any, lifetime, preferred, flags));
|
||||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
|
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss));
|
||||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
|
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss));
|
||||||
|
@@ -563,8 +563,8 @@ _ip_address_add (gboolean external_command,
|
|||||||
const NMIPAddr *peer_address,
|
const NMIPAddr *peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
const char *label,
|
guint32 flags,
|
||||||
guint32 flags)
|
const char *label)
|
||||||
{
|
{
|
||||||
gint64 end_time;
|
gint64 end_time;
|
||||||
|
|
||||||
@@ -626,7 +626,6 @@ _ip_address_add (gboolean external_command,
|
|||||||
gboolean success;
|
gboolean success;
|
||||||
|
|
||||||
if (is_v4) {
|
if (is_v4) {
|
||||||
g_assert (flags == 0);
|
|
||||||
success = nm_platform_ip4_address_add (NM_PLATFORM_GET,
|
success = nm_platform_ip4_address_add (NM_PLATFORM_GET,
|
||||||
ifindex,
|
ifindex,
|
||||||
address->addr4,
|
address->addr4,
|
||||||
@@ -634,6 +633,7 @@ _ip_address_add (gboolean external_command,
|
|||||||
peer_address->addr4,
|
peer_address->addr4,
|
||||||
lifetime,
|
lifetime,
|
||||||
preferred,
|
preferred,
|
||||||
|
flags,
|
||||||
label);
|
label);
|
||||||
} else {
|
} else {
|
||||||
g_assert (label == NULL);
|
g_assert (label == NULL);
|
||||||
@@ -1006,6 +1006,7 @@ nmtstp_ip4_address_add (gboolean external_command,
|
|||||||
in_addr_t peer_address,
|
in_addr_t peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
|
guint32 flags,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
_ip_address_add (external_command,
|
_ip_address_add (external_command,
|
||||||
@@ -1016,8 +1017,8 @@ nmtstp_ip4_address_add (gboolean external_command,
|
|||||||
(NMIPAddr *) &peer_address,
|
(NMIPAddr *) &peer_address,
|
||||||
lifetime,
|
lifetime,
|
||||||
preferred,
|
preferred,
|
||||||
label,
|
flags,
|
||||||
0);
|
label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1038,8 +1039,8 @@ nmtstp_ip6_address_add (gboolean external_command,
|
|||||||
(NMIPAddr *) &peer_address,
|
(NMIPAddr *) &peer_address,
|
||||||
lifetime,
|
lifetime,
|
||||||
preferred,
|
preferred,
|
||||||
NULL,
|
flags,
|
||||||
flags);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -117,6 +117,7 @@ void nmtstp_ip4_address_add (gboolean external_command,
|
|||||||
in_addr_t peer_address,
|
in_addr_t peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
|
guint32 flags,
|
||||||
const char *label);
|
const char *label);
|
||||||
void nmtstp_ip6_address_add (gboolean external_command,
|
void nmtstp_ip6_address_add (gboolean external_command,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
@@ -125,7 +126,7 @@ void nmtstp_ip6_address_add (gboolean external_command,
|
|||||||
struct in6_addr peer_address,
|
struct in6_addr peer_address,
|
||||||
guint32 lifetime,
|
guint32 lifetime,
|
||||||
guint32 preferred,
|
guint32 preferred,
|
||||||
guint flags);
|
guint32 flags);
|
||||||
void nmtstp_ip4_address_del (gboolean external_command,
|
void nmtstp_ip4_address_del (gboolean external_command,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
in_addr_t address,
|
in_addr_t address,
|
||||||
|
Reference in New Issue
Block a user