Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. Re: Issues Building ConnMan 1.31 Caused By Unknown Source
      (Daniel Wagner)
   2. [PATCH] resolver: Add function to set fallback nameservers
      (Patrik Flykt)
   3. [PATCH] nat: Remember previous IPv4 forwarding value
      (Patrik Flykt)
   4. [PATCH 1/1] service: Fix memory leak in
      __connman_service_nameserver_append (Ravi Prasad RK)
   5. Re: [PATCH] nat: Remember previous IPv4 forwarding value
      (Patrik Flykt)
   6. [PATCH 1/1] service: Fix memory leak in
      __connman_service_nameserver_append (Ravi Prasad RK)
   7. firewall: Remove old rules (Jose Blanquicet)
   8. [PATCH] firewall: Remove old rules (Jose Blanquicet)


----------------------------------------------------------------------

Message: 1
Date: Mon, 11 Apr 2016 10:53:21 +0200
From: Daniel Wagner <[email protected]>
To: Ted Moseley <[email protected]>, [email protected]
Subject: Re: Issues Building ConnMan 1.31 Caused By Unknown Source
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252

Hi Ted,

On 04/10/2016 06:28 PM, Ted Moseley wrote:
> Hi, I am attempting to build ConnMan 1.31 on a Linux from Scratch
> systemd build. Unfortunately, I am having these errors come up in the
> middle of building, and I am not quite sure why. If someone could give
> me some advice on how to fix this issue, or at least get around it for
> now, that would be great. I thought it was just an issue with iptables.
> but after some research, it seems to deal with the kernel and glibc. So
> any help will be much appreciated. Note: I have glib 4.48 and iptables
> 1.6.0 installed, and have Linux 4.5 as my kernel. I have also attempted
> using the latest git master, and similar results occurred.
> 
> Here is the build log when I ran make:

[...]

>   CC       tools/private-network-test.o
>  In file included from /usr/include/xtables.h:16:0,
>                  from src/iptables.c:33:
> /usr/include/linux/if.h:71:2: error: redeclaration of enumerator 'IFF_UP'
>   IFF_UP    = 1<<0,  /* sysfs */
>   ^
> /usr/include/net/if.h:44:5: note: previous definition of 'IFF_UP' was here
>      IFF_UP = 0x1,  /* Interface is up.  */
>      ^

Hmm, xtables pulls linux/if.h and net/if.h for some reason. I checked
on my system and I only see net/if.


# 16 "/usr/include/xtables.h" 2 3 4
# 1 "/usr/include/net/if.h" 1 3 4
# 33 "/usr/include/net/if.h" 3 4
struct if_nameindex
  {
    unsigned int if_index;
    char *if_name;
  };

enum
  {
    IFF_UP = 0x1,


Here is my command line, maybe it helps.

$ make V=1 src/iptables.o 
depbase=`echo src/iptables.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I.  -I./include -I./gdbus  -I/usr/include/dbus-1.0 
-I/usr/lib64/dbus-1.0/include  -I/usr/include/glib-2.0 
-I/usr/lib64/glib-2.0/include -I/usr/include/p11-kit-1   
-DCONNMAN_PLUGIN_BUILTIN -DSTATEDIR=\""/var/run/connman"\" 
-DVPN_STATEDIR=\""/var/run/connman-vpn"\" 
-DPLUGINDIR=\""/home/wagi/connman/connman/plugins/.libs"\" 
-DSCRIPTDIR=\""/home/wagi/connman/connman/scripts"\" 
-DSTORAGEDIR=\""/var/lib/connman\"" -DVPN_STORAGEDIR=\""/var/lib/connman-vpn\"" 
-DCONFIGDIR=\""/etc/connman\"" -Wall -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 
-Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers 
-Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls 
-Wcast-align -DG_DISABLE_DEPRECATED -O0 -U_FORTIFY_SOURCE -g -MT src/iptables.o 
-MD -MP -MF $depbase.Tpo -c -o src/iptables.o src/iptables.c &&\
mv -f $depbase.Tpo $depbase.Po



cheers,
daniel


------------------------------

Message: 2
Date: Mon, 11 Apr 2016 13:29:09 +0300
From: Patrik Flykt <[email protected]>
To: [email protected],       [email protected]
Subject: [PATCH] resolver: Add function to set fallback nameservers
Message-ID:
        <[email protected]>

Make an internal function to request fallback nameservers to be added
in case no nameservers were configured for the service.
---

This one is also needed in addition to "[PATCH] dnsproxy: Enable fallback 
nameservers when default service changes".

Please test,

       Patrik


src/connman.h  | 1 +
 src/resolver.c | 4 ++--
 src/service.c  | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 447bdd7..c74ab91 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -248,6 +248,7 @@ int __connman_inet_get_address_netmask(int ifindex,
 
 int __connman_resolver_init(gboolean dnsproxy);
 void __connman_resolver_cleanup(void);
+void __connman_resolver_append_fallback_nameservers(void);
 int __connman_resolvfile_append(int index, const char *domain, const char 
*server);
 int __connman_resolvfile_remove(int index, const char *domain, const char 
*server);
 int __connman_resolver_redo_servers(int index);
diff --git a/src/resolver.c b/src/resolver.c
index 121b71c..fbe4be7 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -218,7 +218,7 @@ int __connman_resolvfile_remove(int index, const char 
*domain,
        return resolvfile_export();
 }
 
-static void append_fallback_nameservers(void)
+void __connman_resolver_append_fallback_nameservers(void)
 {
        GSList *list;
 
@@ -295,7 +295,7 @@ static void remove_entries(GSList *entries)
 
        g_slist_free(entries);
 
-       append_fallback_nameservers();
+       __connman_resolver_append_fallback_nameservers();
 }
 
 static gboolean resolver_expire_cb(gpointer user_data)
diff --git a/src/service.c b/src/service.c
index 8e07337..86fa382 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1041,6 +1041,7 @@ static int nameserver_add_all(struct connman_service 
*service,
                        i++;
                }
        }
+       __connman_resolver_append_fallback_nameservers();
 
        searchdomain_add_all(service);
 
-- 
2.8.0.rc3



------------------------------

Message: 3
Date: Mon, 11 Apr 2016 13:31:17 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH] nat: Remember previous IPv4 forwarding value
Message-ID:
        <[email protected]>

When NAT is enabled, store the previous IPv4 forwarding setting so that
it can be restored to its former value when disabling NAT.
---
 src/nat.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/nat.c b/src/nat.c
index 063f085..512cbac 100644
--- a/src/nat.c
+++ b/src/nat.c
@@ -25,7 +25,10 @@
 #endif
 
 #include <errno.h>
-#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 #include "connman.h"
 
@@ -42,20 +45,32 @@ struct connman_nat {
 
 static int enable_ip_forward(bool enable)
 {
-       FILE *f;
+       static char value = 0;
+       int f, err;
 
-       f = fopen("/proc/sys/net/ipv4/ip_forward", "r+");
-       if (!f)
+       if ((f = open("/proc/sys/net/ipv4/ip_forward", O_CLOEXEC)) < 0)
                return -errno;
 
-       if (enable)
-               fprintf(f, "1");
-       else
-               fprintf(f, "0");
+       if (!value) {
+               if (read(f, &value, sizeof(value)) < 0)
+                       value = 0;
+       }
 
-       fclose(f);
+       if (enable) {
+               char allow = '1';
 
-       return 0;
+               err = write (f, &allow, sizeof(allow));
+       } else {
+               char deny = '0';
+
+               err = write(f, value? &value: &deny, sizeof(value));
+               value = 0;
+       }
+
+       DBG("enable %d prev value '%c' err %d", enable, value, err);
+       close(f);
+
+       return (err < 0? err: 0);
 }
 
 static int enable_nat(struct connman_nat *nat)
-- 
2.8.0.rc3



------------------------------

Message: 4
Date: Mon, 11 Apr 2016 16:57:50 +0530
From: Ravi Prasad RK <[email protected]>
To: [email protected]
Cc: Ravi Prasad RK <[email protected]>
Subject: [PATCH 1/1] service: Fix memory leak in
        __connman_service_nameserver_append
Message-ID: <[email protected]>

---
 src/service.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 8e07337..d9abbc4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1127,8 +1127,10 @@ int __connman_service_nameserver_append(struct 
connman_service *service,
                return -ENOMEM;
 
        nameservers[len] = g_strdup(nameserver);
-       if (!nameservers[len])
+       if (!nameservers[len]) {
+               g_strfreev(nameservers);
                return -ENOMEM;
+       }
 
        nameservers[len + 1] = NULL;
 
-- 
1.7.9.5



------------------------------

Message: 5
Date: Mon, 11 Apr 2016 15:07:05 +0300
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: Re: [PATCH] nat: Remember previous IPv4 forwarding value
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"

On Mon, 2016-04-11 at 13:31 +0300, Patrik Flykt wrote:
> +???????DBG("enable %d prev value '%c' err %d", enable, value, err);
> +???????close(f);
> +
> +???????return (err < 0? err: 0);

An extra debug slipped through, and the return statement needs to be a
bit better formulated.


        Patrik


------------------------------

Message: 6
Date: Mon, 11 Apr 2016 18:03:03 +0530
From: Ravi Prasad RK <[email protected]>
To: [email protected]
Cc: Ravi Prasad RK <[email protected]>
Subject: [PATCH 1/1] service: Fix memory leak in
        __connman_service_nameserver_append
Message-ID: <[email protected]>

---
 src/service.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 8e07337..d9abbc4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1127,8 +1127,10 @@ int __connman_service_nameserver_append(struct 
connman_service *service,
                return -ENOMEM;
 
        nameservers[len] = g_strdup(nameserver);
-       if (!nameservers[len])
+       if (!nameservers[len]) {
+               g_strfreev(nameservers);
                return -ENOMEM;
+       }
 
        nameservers[len + 1] = NULL;
 
-- 
1.7.9.5



------------------------------

Message: 7
Date: Mon, 11 Apr 2016 15:23:37 +0200
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: firewall: Remove old rules
Message-ID: <[email protected]>

When a new service becomes ready or online, it's checked if its technology 
is more preferred than the one used by the currrent default gateway. 
If so, this new service becomes the new default gateway.

When the tethering is enabled, a NAT rule is created to forward the 
traffic between the interface playing the AP role and the interface 
connected to current default gateway. The problem comes out when the
default gateway changes, because the NAT rule is disabled but not 
removed from the firewall's rules list. Therefore, when the new rule is 
installed also the old rule is installed because it is still in the list.
If it changes again, then three rules will be installed, and so on. They
are never removed.

This patch adds a deletion of all the rules from the firewall list exactly
after they are disabled to avoid the described problem. 

Jose Blanquicet (1):
  firewall: Remove old rules

 src/firewall.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

-- 
1.9.1



------------------------------

Message: 8
Date: Mon, 11 Apr 2016 15:24:10 +0200
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH] firewall: Remove old rules
Message-ID: <[email protected]>

---
 src/firewall.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/firewall.c b/src/firewall.c
index c5acc11..0baba6b 100644
--- a/src/firewall.c
+++ b/src/firewall.c
@@ -438,7 +438,13 @@ int __connman_firewall_enable(struct firewall_context *ctx)
 
 int __connman_firewall_disable(struct firewall_context *ctx)
 {
-       return __connman_firewall_disable_rule(ctx, FW_ALL_RULES);
+       int err;
+       
+       err = __connman_firewall_disable_rule(ctx, FW_ALL_RULES);
+       if (err < 0)
+               return err;
+       
+       return __connman_firewall_remove_rule(ctx, FW_ALL_RULES);
 }
 
 bool __connman_firewall_is_up(void)
-- 
1.9.1



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 6, Issue 6
*************************************

Reply via email to