From: Jukka Rissanen <[email protected]>
---
src/device.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/src/device.c b/src/device.c
index 2ec544d..c9e643d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -72,6 +72,17 @@ struct connman_device {
uint32_t fwmark;
};
+/*
+ * Tie the fwmarker number to interface index number, substract 1 because
+ * indexes are > 0
+ */
+static uint32_t get_fwmarker_id(int ifindex)
+{
+ const uint32_t value = ('c' << 24) | ('m' << 16) | ('a' << 8) | 'n';
+
+ return value + ifindex - 1;
+}
+
static void clear_pending_trigger(struct connman_device *device)
{
if (device->pending_timeout > 0) {
@@ -291,10 +302,24 @@ static void probe_driver(struct connman_device_driver
*driver)
static void remove_device(struct connman_device *device)
{
+ int ret;
+
DBG("device %p", device);
__connman_device_disable(device);
+ ret = __connman_inet_del_fwmark_rule(device->index, AF_INET,
+ device->fwmark);
+ if (ret < 0)
+ DBG("Marker removal failed %d for IPv4, index %d fwmark %d",
+ ret, device->index, device->fwmark);
+
+ ret = __connman_inet_del_fwmark_rule(device->index, AF_INET6,
+ device->fwmark);
+ if (ret < 0)
+ DBG("Marker removal failed %d for IPv6, index %d fwmark %d",
+ ret, device->index, device->fwmark);
+
__connman_technology_remove_device(device);
if (device->driver->remove)
@@ -506,7 +531,23 @@ enum connman_device_type connman_device_get_type(struct
connman_device *device)
*/
void connman_device_set_index(struct connman_device *device, int index)
{
+ int ret;
+
device->index = index;
+
+ device->fwmark = get_fwmarker_id(index);
+
+ DBG("index %d fwmark %u", index, device->fwmark);
+
+ ret = __connman_inet_add_fwmark_rule(index, AF_INET, device->fwmark);
+ if (ret < 0)
+ DBG("Marker set failed %d for IPv4, index %d fwmark %u",
+ ret, index, device->fwmark);
+
+ ret = __connman_inet_add_fwmark_rule(index, AF_INET6, device->fwmark);
+ if (ret < 0)
+ DBG("Marker set failed %d for IPv6, index %d fwmark %u",
+ ret, index, device->fwmark);
}
/**
--
1.7.12.rc1.16.g05a20c8
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman