Commit 684e80b5 authored by Thomas Haller's avatar Thomas Haller

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.
parent cc78e063
......@@ -80,7 +80,7 @@ test_arping_common (test_fixture *fixture, TestInfo *info)
for (i = 0; info->peer_addresses[i]; 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);
......
......@@ -890,6 +890,7 @@ ip4_address_add (NMPlatform *platform,
in_addr_t peer_addr,
guint32 lifetime,
guint32 preferred,
guint32 flags,
const char *label)
{
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.lifetime = lifetime;
address.preferred = preferred;
address.n_ifa_flags = flags;
if (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);
}
if (flags & ~0xFF) {
if (flags & ~((guint32) 0xFF)) {
/* only set the IFA_FLAGS attribute, if they actually contain additional
* flags that are not already set to am.ifa_flags.
*
......@@ -5182,6 +5182,7 @@ ip4_address_add (NMPlatform *platform,
in_addr_t peer_addr,
guint32 lifetime,
guint32 preferred,
guint32 flags,
const char *label)
{
NMPObject obj_id;
......@@ -5194,7 +5195,7 @@ ip4_address_add (NMPlatform *platform,
&addr,
plen,
&peer_addr,
0,
flags,
nmp_utils_ip4_address_is_link_local (addr) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE,
lifetime,
preferred,
......
......@@ -2453,6 +2453,7 @@ nm_platform_ip4_address_add (NMPlatform *self,
in_addr_t peer_address,
guint32 lifetime,
guint32 preferred,
guint32 flags,
const char *label)
{
_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.lifetime = lifetime;
addr.preferred = preferred;
addr.n_ifa_flags = flags;
if (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));
}
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
......@@ -2667,7 +2669,9 @@ nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known
now, ADDRESS_LIFETIME_PADDING, &lifetime, &preferred))
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;
if (out_added_addresses) {
......
......@@ -591,6 +591,7 @@ typedef struct {
in_addr_t peer_address,
guint32 lifetime,
guint32 preferred_lft,
guint32 flags,
const char *label);
gboolean (*ip6_address_add) (NMPlatform *,
int ifindex,
......@@ -858,6 +859,7 @@ gboolean nm_platform_ip4_address_add (NMPlatform *self,
in_addr_t peer_address,
guint32 lifetime,
guint32 preferred_lft,
guint32 flags,
const char *label);
gboolean nm_platform_ip6_address_add (NMPlatform *self,
int ifindex,
......
......@@ -94,12 +94,12 @@ test_ip4_address_general (void)
/* Add address */
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));
accept_signal (address_added);
/* 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);
/* 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));
/* 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);
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);
......@@ -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));
/* 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));
accept_signal (address_added);
......@@ -273,7 +273,7 @@ test_ip4_address_peer (void)
accept_signals (address_added, 0, G_MAXINT);
/* 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);
a = nm_platform_ip4_address_get (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, addr_peer);
g_assert (a);
......@@ -281,7 +281,7 @@ test_ip4_address_peer (void)
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);
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);
......@@ -328,7 +328,7 @@ test_ip4_address_peer_zero (void)
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]));
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);
g_assert (addrs);
......
......@@ -63,7 +63,7 @@ test_cleanup_internal (void)
g_assert (ifindex > 0);
/* 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_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));
......
......@@ -563,8 +563,8 @@ _ip_address_add (gboolean external_command,
const NMIPAddr *peer_address,
guint32 lifetime,
guint32 preferred,
const char *label,
guint32 flags)
guint32 flags,
const char *label)
{
gint64 end_time;
......@@ -626,7 +626,6 @@ _ip_address_add (gboolean external_command,
gboolean success;
if (is_v4) {
g_assert (flags == 0);
success = nm_platform_ip4_address_add (NM_PLATFORM_GET,
ifindex,
address->addr4,
......@@ -634,6 +633,7 @@ _ip_address_add (gboolean external_command,
peer_address->addr4,
lifetime,
preferred,
flags,
label);
} else {
g_assert (label == NULL);
......@@ -1006,6 +1006,7 @@ nmtstp_ip4_address_add (gboolean external_command,
in_addr_t peer_address,
guint32 lifetime,
guint32 preferred,
guint32 flags,
const char *label)
{
_ip_address_add (external_command,
......@@ -1016,8 +1017,8 @@ nmtstp_ip4_address_add (gboolean external_command,
(NMIPAddr *) &peer_address,
lifetime,
preferred,
label,
0);
flags,
label);
}
void
......@@ -1038,8 +1039,8 @@ nmtstp_ip6_address_add (gboolean external_command,
(NMIPAddr *) &peer_address,
lifetime,
preferred,
NULL,
flags);
flags,
NULL);
}
static void
......
......@@ -117,6 +117,7 @@ void nmtstp_ip4_address_add (gboolean external_command,
in_addr_t peer_address,
guint32 lifetime,
guint32 preferred,
guint32 flags,
const char *label);
void nmtstp_ip6_address_add (gboolean external_command,
int ifindex,
......@@ -125,7 +126,7 @@ void nmtstp_ip6_address_add (gboolean external_command,
struct in6_addr peer_address,
guint32 lifetime,
guint32 preferred,
guint flags);
guint32 flags);
void nmtstp_ip4_address_del (gboolean external_command,
int ifindex,
in_addr_t address,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment