platform: add mss attribute to NMPlatformIP*Route

This commit is contained in:
Pavel Šimerda
2013-05-02 08:42:13 +02:00
parent 9ce458256d
commit 2c656e37dd
4 changed files with 15 additions and 5 deletions

View File

@@ -661,6 +661,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, in_addr_t network, int plen,
route.plen = plen;
route.gateway = gateway;
route.metric = metric;
route.mss = mss;
g_array_append_val (priv->ip4_routes, route);
@@ -682,6 +683,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, struct in6_addr network, int p
route.plen = plen;
route.gateway = gateway;
route.metric = metric;
route.mss = mss;
g_array_append_val (priv->ip6_routes, route);

View File

@@ -418,6 +418,7 @@ init_ip4_route (NMPlatformIP4Route *route, struct rtnl_route *rtnlroute)
if (gw)
memcpy (&route->gateway, nl_addr_get_binary_addr (gw), sizeof (route->gateway));
route->metric = rtnl_route_get_priority (rtnlroute);
rtnl_route_get_metric (rtnlroute, RTAX_ADVMSS, &route->mss);
}
static void
@@ -438,6 +439,7 @@ init_ip6_route (NMPlatformIP6Route *route, struct rtnl_route *rtnlroute)
if (gw)
memcpy (&route->gateway, nl_addr_get_binary_addr (gw), sizeof (route->gateway));
route->metric = rtnl_route_get_priority (rtnlroute);
rtnl_route_get_metric (rtnlroute, RTAX_ADVMSS, &route->mss);
}
/******************************************************************/

View File

@@ -84,7 +84,8 @@ typedef struct {
in_addr_t network;
int plen;
in_addr_t gateway;
int metric;
guint metric;
guint mss;
} NMPlatformIP4Route;
typedef struct {
@@ -92,7 +93,8 @@ typedef struct {
struct in6_addr network;
int plen;
struct in6_addr gateway;
int metric;
guint metric;
guint mss;
} NMPlatformIP6Route;
/******************************************************************/

View File

@@ -56,7 +56,7 @@ test_ip4_route ()
inet_pton (AF_INET, "198.51.100.0", &gateway);
/* Add route to gateway */
g_assert (nm_platform_ip4_route_add (ifindex, gateway, 32, INADDR_ANY, metric, 0)); no_error ();
g_assert (nm_platform_ip4_route_add (ifindex, gateway, 32, INADDR_ANY, metric, mss)); no_error ();
accept_signal (route_added);
/* Add route */
@@ -77,11 +77,13 @@ test_ip4_route ()
rts[0].ifindex = ifindex;
rts[0].gateway = INADDR_ANY;
rts[0].metric = metric;
rts[0].mss = mss;
rts[1].network = network;
rts[1].plen = plen;
rts[1].ifindex = ifindex;
rts[1].gateway = gateway;
rts[1].metric = metric;
rts[1].mss = mss;
g_assert_cmpint (routes->len, ==, 2);
g_assert (!memcmp (routes->data, rts, sizeof (rts)));
g_array_unref (routes);
@@ -116,8 +118,8 @@ test_ip6_route ()
inet_pton (AF_INET6, "2001:db8:a:b:0:0:0:0", &network);
inet_pton (AF_INET6, "2001:db8:c:d:1:2:3:4", &gateway);
/* Add gateway address */
g_assert (nm_platform_ip6_route_add (ifindex, gateway, 128, in6addr_any, metric, 0)); no_error ();
/* Add route to gateway */
g_assert (nm_platform_ip6_route_add (ifindex, gateway, 128, in6addr_any, metric, mss)); no_error ();
accept_signal (route_added);
/* Add route */
@@ -138,11 +140,13 @@ test_ip6_route ()
rts[0].ifindex = ifindex;
rts[0].gateway = in6addr_any;
rts[0].metric = metric;
rts[0].mss = mss;
rts[1].network = network;
rts[1].plen = plen;
rts[1].ifindex = ifindex;
rts[1].gateway = gateway;
rts[1].metric = metric;
rts[1].mss = mss;
g_assert_cmpint (routes->len, ==, 2);
g_assert (!memcmp (routes->data, rts, sizeof (rts)));
g_array_unref (routes);