Re: [OpenWrt-Devel] Howto force mips64

2014-06-17 Thread Martin Fäcknitz
force mips64 support is quite simple: set

  CPU_CFLAGS_octeon=-march=octeon -mabi=64

inside target/linux/octeon/Makefile and replace the same line in
include/target.mk. Finally you have to add the following patch:

diff --git a/target/linux/octeon/patches-3.10/-cn61xx_support.patch
b/target/linux/octeon/patches-3.10/-cn61xx_support.patch
new file mode 100644
index 000..18d2f3d
--- /dev/null
+++ b/target/linux/octeon/patches-3.10/-cn61xx_support.patch
@@ -0,0 +1,47 @@
+Index: b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c
+===
+--- a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c2014-05-06
15:24:06.0 +0200
 b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c2014-05-06
15:25:14.0 +0200
+@@ -75,6 +75,8 @@
+ int cvmx_helper_board_get_mii_address(int ipd_port)
+ {
+   switch (cvmx_sysinfo_get()->board_type) {
++  case 20003:
++  return -1;
+   case CVMX_BOARD_TYPE_SIM:
+   /* Simulator doesn't have MII */
+   return -1;
+Index: b/arch/mips/cavium-octeon/executive/cvmx-helper.c
+===
+--- a/arch/mips/cavium-octeon/executive/cvmx-helper.c  2014-01-25
17:27:55.0 +0100
 b/arch/mips/cavium-octeon/executive/cvmx-helper.c  2014-05-06
15:25:47.0 +0200
+@@ -83,7 +83,7 @@
+  */
+ int cvmx_helper_get_number_of_interfaces(void)
+ {
+-  if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
++  if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX) ||
OCTEON_IS_MODEL(OCTEON_CN61XX))
+   return 4;
+   else
+   return 3;
+@@ -121,7 +121,8 @@
+
+   if (interface == 3) {
+   if (OCTEON_IS_MODEL(OCTEON_CN56XX)
+-  || OCTEON_IS_MODEL(OCTEON_CN52XX))
++  || OCTEON_IS_MODEL(OCTEON_CN52XX)
++  || OCTEON_IS_MODEL(OCTEON_CN6XXX))
+   return CVMX_HELPER_INTERFACE_MODE_LOOP;
+   else
+   return CVMX_HELPER_INTERFACE_MODE_DISABLED;
+@@ -152,7 +153,9 @@
+
+   mode.u64 = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
+
+-  if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) {
++  if (OCTEON_IS_MODEL(OCTEON_CN61XX)) {
++  return CVMX_HELPER_INTERFACE_MODE_SGMII;
++  } else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || 
OCTEON_IS_MODEL(OCTEON_CN52XX)) {
+   switch (mode.cn56xx.mode) {
+   case 0:
+   return CVMX_HELPER_INTERFACE_MODE_DISABLED;

uclibc's mips64 support is broken, so you have to use glibc. gcc-4.8
doesn't work for me (invalid TLS related code), therefore use gcc-4.6.

greets

On 16.06.2014 23:26, Edison Figueira Junior wrote:
> hello, I can be a beta test if you want :-)
> 
> Enviada do meu iPhone
> 
>> Em 04/06/2014, às 10:05, John Crispin  escreveu:
>>
>> octeon is currently only partially working. we will push a fix to
>> trunk in the next few days. experimental patch is currently in
>> testing. please be patient for a few dyas
>>
>>
>>> On 04/06/2014 14:36, Edison Figueira Junior wrote:
>>> Howto force to use mips64 for target octeon?
>>>
>>>
>>>
>>>
>>> ___ openwrt-devel
>>> mailing list openwrt-devel@lists.openwrt.org 
>>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>> ___
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 


-- 
Martin Fäcknitz

hotsplots GmbH
Rotherstr. 17
10245 Berlin
Fon: +49 (0)30 29 77 348-48
Fax: +49 (0)30 29 77 348-99
E-Mail: faeckn...@hotsplots.de

Amtsgericht Charlottenburg HRB 93460B
Geschäftsführung: Dr. Ulrich Meier, Dr. Jörg Ontrup
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Howto force mips64

2014-06-17 Thread John Crispin


On 17/06/2014 11:24, Martin Fäcknitz wrote:
> uclibc's mips64 support is broken, so you have to use glibc.
> gcc-4.8 doesn't work for me (invalid TLS related code), therefore
> use gcc-4.6.

Hi,

yes, utterly broken :) i have been talking to the guys at imgtec about
this and there are people working on this matter. i would expect it to
take a few months though until this is all fixed and has treacled down
to openwrt.

John
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Howto force mips64

2014-06-17 Thread Martin Fäcknitz
Hi,

here are the patches which will fix the uclibc-mips64-tls problem:

--- a/toolchain/uClibc/patches-0.9.33.2/999-mips64-tprel.patch
+++ b/toolchain/uClibc/patches-0.9.33.2/999-mips64-tprel.patch
@@ -1,8 +1,19 @@
 Index: b/ldso/ldso/mips/elfinterp.c
 ===
 a/ldso/ldso/mips/elfinterp.c   2014-02-12 16:54:05.0 +0100
-+++ b/ldso/ldso/mips/elfinterp.c   2014-02-12 16:54:15.0 +0100
-@@ -248,22 +248,22 @@
+--- a/ldso/ldso/mips/elfinterp.c   2012-05-15 09:20:09.0 +0200
 b/ldso/ldso/mips/elfinterp.c   2014-05-07 17:20:25.0 +0200
+@@ -239,31 +239,31 @@
+   case R_MIPS_TLS_DTPMOD64:
+   case R_MIPS_TLS_DTPMOD32:
+   if (tls_tpnt)
+-  *(ElfW(Word) 
*)reloc_addr = tls_tpnt->l_tls_modid;
++  *(ElfW(Addr) 
*)reloc_addr = tls_tpnt->l_tls_modid;
+ #ifdef __SUPPORT_LD_DEBUG__
+   _dl_dprintf(2, "TLS_DTPMOD : 
%s, %d, %d\n",
+-  symname, old_val, 
*((unsigned int *)reloc_addr));
++  symname, old_val, 
*((unsigned long *)reloc_addr));
+ #endif
+   break;
  
case R_MIPS_TLS_DTPREL64:
case R_MIPS_TLS_DTPREL32:
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/999-mips64-misc.patch
@@ -0,0 +1,141 @@
+Index: b/libc/sysdeps/linux/mips/sysdep.h
+===
+--- a/libc/sysdeps/linux/mips/sysdep.h 2012-05-15 09:20:09.0 +0200
 b/libc/sysdeps/linux/mips/sysdep.h 2014-02-15 14:10:01.0 +0100
+@@ -288,93 +288,52 @@
+of GCC 3.4.3, this is sufficient.  */
+ #define FORCE_FRAME_POINTER alloca (4)
+ 
+-#undef internal_syscall5
+-#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, 
arg4, arg5)\
+-({\
++#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, 
arg4, arg5) \
++({\
+   long _sys_result;   \
+   \
+-  FORCE_FRAME_POINTER;\
+   {   \
+-  register long __v0 __asm__("$2") ncs_init;  \
+-  register long __a0 __asm__("$4") = (long) arg1; \
+-  register long __a1 __asm__("$5") = (long) arg2; \
+-  register long __a2 __asm__("$6") = (long) arg3; \
+-  register long __a3 __asm__("$7") = (long) arg4; \
+-  __asm__ __volatile__ (  \
+-  ".set\tnoreorder\n\t"   \
+-  "subu\t$29, 32\n\t" \
+-  "sw\t%6, 16($29)\n\t"   \
++  register ARG_TYPE __v0 __asm__("$2") ncs_init;  \
++  register ARG_TYPE __a0 __asm__("$4") = (ARG_TYPE) arg1; \
++  register ARG_TYPE __a1 __asm__("$5") = (ARG_TYPE) arg2; \
++  register ARG_TYPE __a2 __asm__("$6") = (ARG_TYPE) arg3; \
++  register ARG_TYPE __a3 __asm__("$7") = (ARG_TYPE) arg4; \
++  register ARG_TYPE __a4 __asm__("$8") = (ARG_TYPE) arg5; \
++  __asm__ __volatile__ (  \
++  ".set\tnoreorder\n\t"   \
+   cs_init \
+-  "syscall\n\t"   \
+-  "addiu\t$29, 32\n\t"\
+-  ".set\treorder" \
+-  : "=r" (__v0), "+r" (__a3)  \
+-  : input, "r" (__a0), "r" (__a1), "r" (__a2),\
+-"r" ((long)arg5)  \
+-  : __SYSCALL_CLOBBERS);  \
++  "syscall\n\t"   \
++  ".set\treorder" \
++  : "=r" (__v0), "+r" (__a3)  \
++  : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
++  : __SYSCALL_CLOBBERS);  \
+   err = __a3;   

[OpenWrt-Devel] [PATCH] iproute2: update version to 3.15.0, refresh patches, add maintainer

2014-06-17 Thread Russell Senior

Signed-off-by: Russell Senior 
---
 package/network/utils/iproute2/Makefile  | 9 +
 package/network/utils/iproute2/patches/006-no_sctp.patch | 4 ++--
 package/network/utils/iproute2/patches/110-extra-ccopts.patch| 2 +-
 package/network/utils/iproute2/patches/200-add-tc_esfq.patch | 2 +-
 .../network/utils/iproute2/patches/210-add-act_connmark.patch| 4 ++--
 package/network/utils/iproute2/patches/300-ip_tiny.patch | 4 ++--
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/package/network/utils/iproute2/Makefile 
b/package/network/utils/iproute2/Makefile
index 7cc2fb4..558855f 100644
--- a/package/network/utils/iproute2/Makefile
+++ b/package/network/utils/iproute2/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=iproute2
-PKG_VERSION:=3.11.0
+PKG_VERSION:=3.15.0
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=http://kernel.org/pub/linux/utils/net/iproute2/
-PKG_MD5SUM:=d7ffb27bc9f0d80577b1f3fb9d1a7689
+PKG_MD5SUM:=5b1711c9d16071959052e369a2682d77
 PKG_BUILD_PARALLEL:=1
 
 
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
@@ -24,8 +24,9 @@ define Package/iproute2/Default
   TITLE:=Routing control utility ($(2))
   SECTION:=net
   CATEGORY:=Network
-  URL:=http://linux-net.osdl.org/index.php/Iproute2
+  
URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
   SUBMENU:=Routing and Redirection
+  MAINTAINER:=Russell Senior 
   DEPENDS:= +libnl-tiny
   VARIANT:=$(1)
 endef
diff --git a/package/network/utils/iproute2/patches/006-no_sctp.patch 
b/package/network/utils/iproute2/patches/006-no_sctp.patch
index a3ed890..d4a0de0 100644
--- a/package/network/utils/iproute2/patches/006-no_sctp.patch
+++ b/package/network/utils/iproute2/patches/006-no_sctp.patch
@@ -1,6 +1,6 @@
 --- a/ip/ipxfrm.c
 +++ b/ip/ipxfrm.c
-@@ -470,7 +470,6 @@ void xfrm_selector_print(struct xfrm_sel
+@@ -469,7 +469,6 @@ void xfrm_selector_print(struct xfrm_sel
switch (sel->proto) {
case IPPROTO_TCP:
case IPPROTO_UDP:
@@ -8,7 +8,7 @@
case IPPROTO_DCCP:
default: /* XXX */
if (sel->sport_mask)
-@@ -1283,7 +1282,6 @@ static int xfrm_selector_upspec_parse(st
+@@ -1282,7 +1281,6 @@ static int xfrm_selector_upspec_parse(st
switch (sel->proto) {
case IPPROTO_TCP:
case IPPROTO_UDP:
diff --git a/package/network/utils/iproute2/patches/110-extra-ccopts.patch 
b/package/network/utils/iproute2/patches/110-extra-ccopts.patch
index 4a08757..0e36230 100644
--- a/package/network/utils/iproute2/patches/110-extra-ccopts.patch
+++ b/package/network/utils/iproute2/patches/110-extra-ccopts.patch
@@ -7,5 +7,5 @@
 -CCOPTS = -O2
 +CCOPTS = -O2 $(EXTRA_CCOPTS)
  WFLAGS := -Wall -Wstrict-prototypes  -Wmissing-prototypes
- WFLAGS += -Wmissing-declarations -Wold-style-definition
+ WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
  
diff --git a/package/network/utils/iproute2/patches/200-add-tc_esfq.patch 
b/package/network/utils/iproute2/patches/200-add-tc_esfq.patch
index f09b450..19d8199 100644
--- a/package/network/utils/iproute2/patches/200-add-tc_esfq.patch
+++ b/package/network/utils/iproute2/patches/200-add-tc_esfq.patch
@@ -10,7 +10,7 @@
  TCMODULES += q_tbf.o
 --- a/include/linux/pkt_sched.h
 +++ b/include/linux/pkt_sched.h
-@@ -222,6 +222,33 @@ struct tc_sfq_xstats {
+@@ -226,6 +226,33 @@ struct tc_sfq_xstats {
__s32   allot;
  };
  
diff --git a/package/network/utils/iproute2/patches/210-add-act_connmark.patch 
b/package/network/utils/iproute2/patches/210-add-act_connmark.patch
index ac6ba33..c0bf07a 100644
--- a/package/network/utils/iproute2/patches/210-add-act_connmark.patch
+++ b/package/network/utils/iproute2/patches/210-add-act_connmark.patch
@@ -1,13 +1,13 @@
 --- a/tc/Makefile
 +++ b/tc/Makefile
-@@ -38,6 +38,7 @@ TCMODULES += m_mirred.o
+@@ -39,6 +39,7 @@ TCMODULES += m_mirred.o
  TCMODULES += m_nat.o
  TCMODULES += m_pedit.o
  TCMODULES += m_skbedit.o
 +TCMODULES += m_connmark.o
  TCMODULES += m_csum.o
+ TCMODULES += m_simple.o
  TCMODULES += p_ip.o
- TCMODULES += p_icmp.o
 --- /dev/null
 +++ b/tc/m_connmark.c
 @@ -0,0 +1,74 @@
diff --git a/package/network/utils/iproute2/patches/300-ip_tiny.patch 
b/package/network/utils/iproute2/patches/300-ip_tiny.patch
index 43afb9c..5b0d56c 100644
--- a/package/network/utils/iproute2/patches/300-ip_tiny.patch
+++ b/package/network/utils/iproute2/patches/300-ip_tiny.patch
@@ -14,7 +14,7 @@
  ALLOBJ=$(IPOBJ) $(RTMONOBJ)
  SCRIPTS=ifcfg rtpr routel routef
  TARGETS=ip rtmon
-@@ -43,7 +50,7 @@ else
+@@ -42,7 +49,7 @@ else
  
  ip: static-syms.o
  static-syms.o: static-syms.h
@@ -28,7 +28

[OpenWrt-Devel] CONFIG_DEBUG and CONFIG_USE_SSTRIP

2014-06-17 Thread Karl Vogel
Currently when CONFIG_DEBUG is enabled, stripping is
disabled and the sstrip option becomes unavailable.

Looking at the commit history I noticed ticket #6373 which
introduced some of these changes. Reading the ticket it
seems the intend was to disable stripping when a user
selected CONFIG_DEBUG.

However the combination of debug + stripping is useful to
create a minimal build but still have the option to remote
gdb or examine core dumps, ie where the target has
stripped binaries, but the unstripped binaries are available
on the host/dev system. So I was wondering if it was
intentional to remove the sstrip option (as GNU strip is still
available) to work around bugs or issues with this
combination? or was it an unfortunate side effect of fixing
this ticket?

Karl
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Problem compiling kernel 3.3.8 in AA

2014-06-17 Thread Francisco Cuesta
2014-06-11 17:17 GMT+02:00 Tijs Van Buggenhout :

>  It seems that the kernel config being generated by openwrt is incomplete
> for some reason. Are you using an old openwrt config to build for a new AA
> revision, without going through the openwrt configuration stage ?
>

Yes I am doing it, I am replacing my own kernel conf file with the options
I wanted. Is that not possible then? Or I have to create at least once a
conf file with the new style,apply my settings and then use it?

Thanks in advance,




>
>
> Files at interest are
> AA/build_dir/linux-ar71xx_generic/linux-3.3.8/.config and AA/.config
> (openwrt config).
>
>
>
> Regards,
>
> Tijs
>
>
>
> On Friday 06 June 2014 20:56:08 Francisco Cuesta wrote:
>
> Hello,  I am trying to compile my trunk version of Attitude Adjustment
> with some USB features enabled for allowing the connection of Atheros USB
> dongles to a tplink WDR4300ND.
>
> However, I am facing always the same problem, the firmware creation
> process is always stopped at the same point, which can be seen below. I
> don't know the reason, Just after that  I am ask to set again what looks
> like the kernel configuration, but I am not prompted any error, as far as I
> can see.
>
> I have just tried to compile the kernel, and I was given back the same
> state...
>
> May anyone enligthen me a bit?
>
> Thanks in advance,
>
> regards!
>
> ...
>
> make[4]: Entering directory 
> `/home/j/openwrt/attitudeAdjustment/build_dir/linux-ar71xx_generic/linux-3.3.8'
>
>   HOSTCC  scripts/kconfig/conf.o
>
>   SHIPPED scripts/kconfig/zconf.tab.c
>
>   SHIPPED scripts/kconfig/zconf.lex.c
>
>   SHIPPED scripts/kconfig/zconf.hash.c
>
>   HOSTCC  scripts/kconfig/zconf.tab.o
>
>   HOSTLD  scripts/kconfig/conf
>
> scripts/kconfig/conf --silentoldconfig Kconfig
>
> *
>
> * Restart config...
>
> *
>
> *
>
> * GCOV-based kernel profiling
>
> *
>
> Enable gcov-based kernel profiling (GCOV_KERNEL) [N/y/?] (NEW)
>
>
>
>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Ramips Image Generation issue

2014-06-17 Thread Alpha Sparc
Can someone please address this bug?
https://dev.openwrt.org/ticket/16599
Thanks

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] lantiq: make loading pci fixup data from cal_data work again

2014-06-17 Thread Ben Mulvihill
Changeset 40948 restored an older (and uglier!) version of the
code for reading the athxk calibration partition on lantiq
xway boards. As a result pci fixups stored in this partition
are no longer applied, breaking wireless on the BTHOMEHUBV2B
and (I imagine) on the DGN3500. This is a minimal patch to
restore this functionality for ath9k without reverting any
of the other changes in changeset 40948.

Note for John Crispin:
I guess you won't want to apply this patch if you are planning
to check changeset 40948 anyway yourself. I produced it for
my own use and thought I might as well send it in in case it
was any use to anyone.

Ben Mulvihill


--- a/arch/mips/lantiq/xway/ath_eep.c   2014-06-16 12:10:10.413893209 +0200
+++ b/arch/mips/lantiq/xway/ath_eep.c   2014-06-16 12:10:26.366264625 +0200
@@ -35,6 +35,7 @@ static int ath9k_pci_plat_dev_init(struc
return 0;
 }
 
+static int ath9k_eep_load;
 int __init of_ath9k_eeprom_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev->dev.of_node, *mtd_np;
@@ -117,6 +118,13 @@ int __init of_ath9k_eeprom_probe(struct
ltq_pci_ath_fixup(pci_slot, ath9k_pdata.eeprom_data);
 
dev_info(&pdev->dev, "pci slot: %u\n", pci_slot);
+if (ath9k_eep_load) {
+struct pci_dev *d = NULL;
+while ((d = pci_get_device(PCI_VENDOR_ID_ATHEROS,
+PCI_ANY_ID, d)) != NULL)
+pci_fixup_device(pci_fixup_early, d);
+}
+
}
 
dev_info(&pdev->dev, "loaded ath9k eeprom\n");
@@ -139,9 +147,22 @@ static struct platform_driver ath9k_eepr
 
 static int __init of_ath9k_eeprom_init(void)
 {
-   return platform_driver_probe(&ath9k_eeprom_driver, 
of_ath9k_eeprom_probe);
+int ret = platform_driver_probe(&ath9k_eeprom_driver, 
of_ath9k_eeprom_probe);
+
+if (ret)
+ath9k_eep_load = 1;
+
+return ret;
+}
+
+static int __init of_ath9k_eeprom_init_late(void)
+{
+if (!ath9k_eep_load)
+return 0;
+return platform_driver_probe(&ath9k_eeprom_driver, 
of_ath9k_eeprom_probe);
 }
-arch_initcall(of_ath9k_eeprom_init);
+late_initcall(of_ath9k_eeprom_init_late);
+subsys_initcall(of_ath9k_eeprom_init);
 
 
 static int ath5k_pci_plat_dev_init(struct pci_dev *dev)
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 0/5] DNSSEC support

2014-06-17 Thread Andre Heider
Hi,

fresh set of patches. Changes against v1:

- building against libnettle-mini is supported now, patch 3 adds an upstream
  fix for this combination.
- switched from a compile time configuration menu to a 3rd variant "full".

Thanks,
Andre

Andre Heider (5):
  dnsmasq: use COPTS for compile time options
  dnsmasq: respect target's LDFLAGS
  dnsmasq: add upstream patch to build against libnettle-mini
  dnsmasq: Add a full variant
  dnsmasq: add UCI DNSSEC runtime support

 package/network/services/dnsmasq/Makefile  | 38 --
 .../network/services/dnsmasq/files/dnsmasq.init|  8 ++
 ...g-add-DNO_GMP-for-use-with-nettle-mini-gm.patch | 88 ++
 3 files changed, 129 insertions(+), 5 deletions(-)
 create mode 100644 
package/network/services/dnsmasq/patches/0001-Build-config-add-DNO_GMP-for-use-with-nettle-mini-gm.patch

-- 
2.0.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 1/5] dnsmasq: use COPTS for compile time options

2014-06-17 Thread Andre Heider
As documented in config.h.
Doing otherwise will break dnsmasq's pkg-wrapper script to find its
libs to link to.

Signed-off-by: Andre Heider 
---
 package/network/services/dnsmasq/Makefile | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/package/network/services/dnsmasq/Makefile 
b/package/network/services/dnsmasq/Makefile
index 8e2d41c..c0d3dc4 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -61,18 +61,19 @@ endef
 
 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
 
-TARGET_CFLAGS += \
-   -ffunction-sections -fdata-sections \
-   $(if $(CONFIG_IPV6),,-DNO_IPV6) -DNO_IPSET -DNO_AUTH
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+
+COPTS = $(if $(CONFIG_IPV6),,-DNO_IPV6) -DNO_IPSET -DNO_AUTH
 
 ifeq ($(BUILD_VARIANT),nodhcpv6)
-  TARGET_CFLAGS += -DNO_DHCP6
+   COPTS += -DNO_DHCP6
 endif
 
 MAKE_FLAGS := \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="-Wl,--gc-sections" \
+   COPTS="$(COPTS)" \
PREFIX="/usr"
 
 define Package/dnsmasq/install
-- 
2.0.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 4/5] dnsmasq: Add a full variant

2014-06-17 Thread Andre Heider
This variant includes support for DHCPv6 and DNSSEC.
DNSSEC adds a dependency on libnettle.

Signed-off-by: Andre Heider 
---
 package/network/services/dnsmasq/Makefile | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/package/network/services/dnsmasq/Makefile 
b/package/network/services/dnsmasq/Makefile
index 8473656..34d543f 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -44,6 +44,13 @@ $(call Package/dnsmasq/Default)
   VARIANT:=dhcpv6
 endef
 
+define Package/dnsmasq-full
+$(call Package/dnsmasq/Default)
+  TITLE += (with DHCPv6 and DNSSEC)
+  DEPENDS:=@IPV6 +kmod-ipv6 +libnettle
+  VARIANT:=full
+endef
+
 define Package/dnsmasq/description
   It is intended to provide coupled DNS and DHCP service to a LAN.
 endef
@@ -54,12 +61,19 @@ $(call Package/dnsmasq/description)
 This is a variant with DHCPv6 support
 endef
 
+define Package/dnsmasq-full/description
+$(call Package/dnsmasq/description)
+
+This is a variant with DHCPv6 and DNSSEC support
+endef
+
 define Package/dnsmasq/conffiles
 /etc/config/dhcp
 /etc/dnsmasq.conf
 endef
 
 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
+Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
 TARGET_LDFLAGS += -Wl,--gc-sections
@@ -70,6 +84,11 @@ ifeq ($(BUILD_VARIANT),nodhcpv6)
COPTS += -DNO_DHCP6
 endif
 
+ifeq ($(BUILD_VARIANT),full)
+   COPTS += -DHAVE_DNSSEC
+   COPTS += $(if $(CONFIG_LIBNETTLE_MINI),-DNO_GMP,)
+endif
+
 MAKE_FLAGS := \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
@@ -91,5 +110,12 @@ endef
 
 Package/dnsmasq-dhcpv6/install = $(Package/dnsmasq/install)
 
+define Package/dnsmasq-full/install
+$(call Package/dnsmasq/install,$(1))
+   $(INSTALL_DIR) $(1)/usr/share/dnsmasq
+   $(INSTALL_DATA) $(PKG_BUILD_DIR)/trust-anchors.conf 
$(1)/usr/share/dnsmasq
+endef
+
 $(eval $(call BuildPackage,dnsmasq))
 $(eval $(call BuildPackage,dnsmasq-dhcpv6))
+$(eval $(call BuildPackage,dnsmasq-full))
-- 
2.0.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 2/5] dnsmasq: respect target's LDFLAGS

2014-06-17 Thread Andre Heider
Append local flags, don't overwrite.

Signed-off-by: Andre Heider 
---
 package/network/services/dnsmasq/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/network/services/dnsmasq/Makefile 
b/package/network/services/dnsmasq/Makefile
index c0d3dc4..8473656 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -62,6 +62,7 @@ endef
 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
 
 COPTS = $(if $(CONFIG_IPV6),,-DNO_IPV6) -DNO_IPSET -DNO_AUTH
 
@@ -72,7 +73,7 @@ endif
 MAKE_FLAGS := \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
-   LDFLAGS="-Wl,--gc-sections" \
+   LDFLAGS="$(TARGET_LDFLAGS)" \
COPTS="$(COPTS)" \
PREFIX="/usr"
 
-- 
2.0.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 5/5] dnsmasq: add UCI DNSSEC runtime support

2014-06-17 Thread Andre Heider
Ship keys for the root zone and add two uci options to enable
DNSSEC checks:

Option 'dnssec': Activate DNSSEC validation
Option 'dnsseccheckunsigned': Ensure answers without DNSSEC are in
unsigned zones.

Signed-off-by: Andre Heider 
---
 package/network/services/dnsmasq/files/dnsmasq.init | 8 
 1 file changed, 8 insertions(+)

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init 
b/package/network/services/dnsmasq/files/dnsmasq.init
index f7edb28..9f16d5f 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -14,6 +14,7 @@ ADD_LOCAL_HOSTNAME=1
 
 CONFIGFILE="/var/etc/dnsmasq.conf"
 HOSTFILE="/tmp/hosts/dhcp"
+TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf"
 
 xappend() {
local value="$1"
@@ -186,6 +187,13 @@ dnsmasq() {
config_list_foreach "$cfg" rebind_domain append_rebind_domain
}
 
+   config_get dnssec "$cfg" dnssec
+   [ "$dnssec" -gt 0 ] && {
+   xappend "--conf-file=$TRUSTANCHORSFILE"
+   xappend "--dnssec"
+   append_bool "$cfg" dnsseccheckunsigned "--dnssec-check-unsigned"
+   }
+
dhcp_option_add "$cfg" "" 0
 
xappend "--dhcp-broadcast=tag:needs-broadcast"
-- 
2.0.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 3/5] dnsmasq: add upstream patch to build against libnettle-mini

2014-06-17 Thread Andre Heider
Signed-off-by: Andre Heider 
---
 ...g-add-DNO_GMP-for-use-with-nettle-mini-gm.patch | 88 ++
 1 file changed, 88 insertions(+)
 create mode 100644 
package/network/services/dnsmasq/patches/0001-Build-config-add-DNO_GMP-for-use-with-nettle-mini-gm.patch

diff --git 
a/package/network/services/dnsmasq/patches/0001-Build-config-add-DNO_GMP-for-use-with-nettle-mini-gm.patch
 
b/package/network/services/dnsmasq/patches/0001-Build-config-add-DNO_GMP-for-use-with-nettle-mini-gm.patch
new file mode 100644
index 000..f9a62cd
--- /dev/null
+++ 
b/package/network/services/dnsmasq/patches/0001-Build-config-add-DNO_GMP-for-use-with-nettle-mini-gm.patch
@@ -0,0 +1,88 @@
+From 063efb330a3f341c2548e2cf1f67f83e49cd6395 Mon Sep 17 00:00:00 2001
+From: Simon Kelley 
+Date: Tue, 17 Jun 2014 19:49:31 +0100
+Subject: [PATCH] Build config: add -DNO_GMP for use with nettle/mini-gmp
+
+---
+ Makefile| 2 +-
+ bld/pkg-wrapper | 9 +++--
+ src/config.h| 7 +++
+ src/dnssec.c| 3 ++-
+ 4 files changed, 17 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index c58b50b..17eeb27 100644
+--- a/Makefile
 b/Makefile
+@@ -61,7 +61,7 @@ lua_cflags =`echo $(COPTS) | $(top)/bld/pkg-wrapper 
HAVE_LUASCRIPT $(PKG_CON
+ lua_libs =  `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT 
$(PKG_CONFIG) --libs lua5.1` 
+ nettle_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC 
$(PKG_CONFIG) --cflags nettle hogweed`
+ nettle_libs =   `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC 
$(PKG_CONFIG) --libs nettle hogweed`
+-gmp_libs =  `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC 
$(PKG_CONFIG) --copy -lgmp`
++gmp_libs =  `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC NO_GMP 
--copy -lgmp`
+ sunos_libs =`if uname | grep SunOS >/dev/null 2>&1; then echo -lsocket 
-lnsl -lposix4; fi`
+ version = -DVERSION='\"`$(top)/bld/get-version $(top)`\"'
+ 
+diff --git a/bld/pkg-wrapper b/bld/pkg-wrapper
+index 9f9332d..0ddb678 100755
+--- a/bld/pkg-wrapper
 b/bld/pkg-wrapper
+@@ -11,9 +11,14 @@ in=`cat`
+ 
+ if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 
|| \
+ echo $in | grep $search >/dev/null 2>&1; then
+-
++# Nasty, nasty, in --copy, arg 2 is another config to search for, use with 
NO_GMP
+ if [ $op = "--copy" ]; then
+-  pkg="$*"
++  if grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 
2>&1 || \
++echo $in | grep $pkg >/dev/null 2>&1; then
++  pkg=""
++  else 
++  pkg="$*"
++  fi
+ elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h 
>/dev/null 2>&1 || \
+ echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
+   pkg=`$pkg  --static $op $*`
+diff --git a/src/config.h b/src/config.h
+index 2155544..ee6d218 100644
+--- a/src/config.h
 b/src/config.h
+@@ -105,6 +105,8 @@ HAVE_AUTH
+define this to include the facility to act as an authoritative DNS
+server for one or more zones.
+ 
++HAVE_DNSSEC
++   include DNSSEC validator.
+ 
+ NO_IPV6
+ NO_TFTP
+@@ -118,6 +120,11 @@ NO_AUTH
+which are enabled  by default in the distributed source tree. Building 
dnsmasq
+with something like "make COPTS=-DNO_SCRIPT" will do the trick.
+ 
++NO_NETTLE_ECC
++   Don't include the ECDSA cypher in DNSSEC validation. Needed for older 
Nettle versions.
++NO_GMP
++   Don't use and link against libgmp, Useful if nettle is built with 
--enable-mini-gmp.
++
+ LEASEFILE
+ CONFFILE
+ RESOLVFILE
+diff --git a/src/dnssec.c b/src/dnssec.c
+index 44d626b..2ffb75d 100644
+--- a/src/dnssec.c
 b/src/dnssec.c
+@@ -26,7 +26,8 @@
+ #  include 
+ #endif
+ #include 
+-#include 
++#include 
++
+ 
+ #define SERIAL_UNDEF  -100
+ #define SERIAL_EQ0
+-- 
+2.0.0
+
-- 
2.0.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/5] netifd: Fix vlan delete via netlink

2014-06-17 Thread Hans Dedecker
Fix vlan delete via netlink as netlink attribute IFLA_IFNAME data size was 
incorrect.
In addition some minor improvements.

Signed-off-by: Hans Dedecker 
---
 system-linux.c |   20 +---
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/system-linux.c b/system-linux.c
index f4721cc..ea71f65 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -808,7 +808,7 @@ int system_vlandev_add(struct device *vlandev, struct 
device *dev, struct vlande
 {
struct nl_msg *msg;
struct nlattr *linkinfo, *data;
-   struct ifinfomsg iim = { .ifi_family = AF_INET };
+   struct ifinfomsg iim = { .ifi_family = AF_UNSPEC };
int ifindex = system_if_resolve(dev);
int rv;
 
@@ -821,14 +821,13 @@ int system_vlandev_add(struct device *vlandev, struct 
device *dev, struct vlande
return -1;
 
nlmsg_append(msg, &iim, sizeof(iim), 0);
-   nla_put(msg, IFLA_IFNAME, IFNAMSIZ, vlandev->ifname);
+   nla_put_string(msg, IFLA_IFNAME, vlandev->ifname);
nla_put_u32(msg, IFLA_LINK, ifindex);

if (!(linkinfo = nla_nest_start(msg, IFLA_LINKINFO)))
goto nla_put_failure;

-   nla_put(msg, IFLA_INFO_KIND, strlen("vlan"), "vlan");
-
+   nla_put_string(msg, IFLA_INFO_KIND, "vlan");
 
if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
goto nla_put_failure;
@@ -859,20 +858,19 @@ nla_put_failure:
 int system_vlandev_del(struct device *vlandev)
 {
struct nl_msg *msg;
-   struct ifinfomsg iim;
-
-   iim.ifi_family = AF_INET;
-   iim.ifi_index  = 0;
+   struct ifinfomsg iim = {
+   .ifi_family = AF_UNSPEC,
+   .ifi_index = 0,
+   };
 
-   msg = nlmsg_alloc_simple(RTM_DELLINK, 0);
+   msg = nlmsg_alloc_simple(RTM_DELLINK, NLM_F_REQUEST);
 
if (!msg)
return -1;
 
nlmsg_append(msg, &iim, sizeof(iim), 0);
 
-   nla_put(msg, IFLA_INFO_KIND, strlen("vlan"), "vlan");
-   nla_put(msg, IFLA_IFNAME, sizeof(vlandev->ifname), vlandev->ifname);
+   nla_put_string(msg, IFLA_IFNAME, vlandev->ifname);
 
system_rtnl_call(msg);
 
-- 
1.7.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/5] netifd: Fix macvlan delete via netlink

2014-06-17 Thread Hans Dedecker
Fix macvlan delete via netlink as netlink attribute IFLA_IFNAME data size was 
incorrect.
In addition some minor improvements.

Signed-off-by: Hans Dedecker 
---
 system-linux.c |   17 -
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/system-linux.c b/system-linux.c
index ea71f65..9b5cffa 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -691,7 +691,7 @@ int system_macvlan_add(struct device *macvlan, struct 
device *dev, struct macvla
 {
struct nl_msg *msg;
struct nlattr *linkinfo, *data;
-   struct ifinfomsg iim = { .ifi_family = AF_INET };
+   struct ifinfomsg iim = { .ifi_family = AF_UNSPEC, };
int ifindex = system_if_resolve(dev);
int i, rv;
static const struct {
@@ -716,13 +716,13 @@ int system_macvlan_add(struct device *macvlan, struct 
device *dev, struct macvla
 
if (cfg->flags & MACVLAN_OPT_MACADDR)
nla_put(msg, IFLA_ADDRESS, sizeof(cfg->macaddr), cfg->macaddr);
-   nla_put(msg, IFLA_IFNAME, IFNAMSIZ, macvlan->ifname);
+   nla_put_string(msg, IFLA_IFNAME, macvlan->ifname);
nla_put_u32(msg, IFLA_LINK, ifindex);
 
if (!(linkinfo = nla_nest_start(msg, IFLA_LINKINFO)))
goto nla_put_failure;
 
-   nla_put(msg, IFLA_INFO_KIND, strlen("macvlan"), "macvlan");
+   nla_put_string(msg, IFLA_INFO_KIND, "macvlan");
 
if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
goto nla_put_failure;
@@ -754,10 +754,10 @@ nla_put_failure:
 int system_macvlan_del(struct device *macvlan)
 {
struct nl_msg *msg;
-   struct ifinfomsg iim;
-
-   iim.ifi_family = AF_INET;
-   iim.ifi_index  = 0;
+   struct ifinfomsg iim = {
+   .ifi_family = AF_UNSPEC,
+   .ifi_index = 0,
+   };
 
msg = nlmsg_alloc_simple(RTM_DELLINK, 0);
 
@@ -766,8 +766,7 @@ int system_macvlan_del(struct device *macvlan)
 
nlmsg_append(msg, &iim, sizeof(iim), 0);
 
-   nla_put(msg, IFLA_INFO_KIND, strlen("macvlan"), "macvlan");
-   nla_put(msg, IFLA_IFNAME, sizeof(macvlan->ifname), macvlan->ifname);
+   nla_put_string(msg, IFLA_IFNAME, macvlan->ifname);
 
system_rtnl_call(msg);
 
-- 
1.7.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 4/5] netifd: Check device_claim return code in all cases

2014-06-17 Thread Hans Dedecker
Fixes observed issue a tunnel interface is reported as up although device_claim 
failed

Signed-off-by: Hans Dedecker 
---
 interface.c   |   12 
 proto-shell.c |4 +++-
 vlan.c|2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/interface.c b/interface.c
index 6ca1d0d..b0fe9de 100644
--- a/interface.c
+++ b/interface.c
@@ -766,8 +766,10 @@ interface_set_l3_dev(struct interface *iface, struct 
device *dev)
device_add_user(&iface->l3_dev, dev);
 
if (dev) {
-   if (claimed)
-   device_claim(&iface->l3_dev);
+   if (claimed) {
+   if (device_claim(&iface->l3_dev) < 0)
+   return;
+   }
interface_ip_set_enabled(&iface->config_ip, enabled);
}
 }
@@ -787,8 +789,10 @@ interface_set_main_dev(struct interface *iface, struct 
device *dev)
return;
}
 
-   if (claimed)
-   device_claim(&iface->l3_dev);
+   if (claimed) {
+   if (device_claim(&iface->l3_dev) < 0)
+   return;
+   }
 
if (!iface->l3_dev.dev)
interface_set_l3_dev(iface, dev);
diff --git a/proto-shell.c b/proto-shell.c
index c4039ed..9fad3a0 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -463,7 +463,9 @@ proto_shell_update_link(struct proto_shell_state *state, 
struct blob_attr *data,
return UBUS_STATUS_INVALID_ARGUMENT;
 
interface_set_l3_dev(iface, dev);
-   device_claim(&iface->l3_dev);
+   if (device_claim(&iface->l3_dev) < 0)
+   return UBUS_STATUS_UNKNOWN_ERROR;
+
device_set_present(dev, true);
 
interface_update_start(iface);
diff --git a/vlan.c b/vlan.c
index 28e561b..28b1441 100644
--- a/vlan.c
+++ b/vlan.c
@@ -50,7 +50,7 @@ static int vlan_set_device_state(struct device *dev, bool up)
}
 
ret = device_claim(&vldev->dep);
-   if (ret)
+   if (ret < 0)
return ret;
 
system_vlan_add(vldev->dep.dev, vldev->id);
-- 
1.7.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 5/5] netifd: Route type support

2014-06-17 Thread Hans Dedecker
Patch adds route type support in netifd by means of the route parameter type.
By default the route type was unicast; the parameter adss support for 
local/broadcast/multicast/unicast routes which will be put into the appropriate 
routing table.
If route type parameter is unset the route type will be unicast as before.

Signed-off-by: Hans Dedecker 
---
 interface-ip.c |   14 ++-
 interface-ip.h |4 ++
 system-dummy.c |6 +++
 system-linux.c |  103 ++-
 system.h   |1 +
 ubus.c |3 ++
 6 files changed, 90 insertions(+), 41 deletions(-)

diff --git a/interface-ip.c b/interface-ip.c
index bd6f164..715e498 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -39,6 +39,7 @@ enum {
ROUTE_TABLE,
ROUTE_SOURCE,
ROUTE_ONLINK,
+   ROUTE_TYPE,
__ROUTE_MAX
 };
 
@@ -53,6 +54,7 @@ static const struct blobmsg_policy route_attr[__ROUTE_MAX] = {
[ROUTE_VALID] = { .name = "valid", .type = BLOBMSG_TYPE_INT32 },
[ROUTE_SOURCE] = { .name = "source", .type = BLOBMSG_TYPE_STRING },
[ROUTE_ONLINK] = { .name = "onlink", .type = BLOBMSG_TYPE_BOOL },
+   [ROUTE_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING }
 };
 
 const struct uci_blob_param_list route_attr_list = {
@@ -374,6 +376,14 @@ interface_ip_add_route(struct interface *iface, struct 
blob_attr *attr, bool v6)
route->valid_until = valid_until;
}
 
+   if ((cur = tb[ROUTE_TYPE]) != NULL) {
+   if (!system_resolve_rt_type(blobmsg_data(cur), &route->type)) {
+   DPRINTF("Failed to resolve routing type: %s\n", (char 
*) blobmsg_data(cur));
+   goto error;
+   }
+   route->flags |= DEVROUTE_TYPE;
+   }
+
vlist_add(&ip->route, &route->node, route);
return;
 
@@ -586,7 +596,8 @@ interface_update_proto_route(struct vlist_tree *tree,
 
if (node_old && node_new)
keep = !memcmp(&route_old->nexthop, &route_new->nexthop, 
sizeof(route_old->nexthop)) &&
-   (route_old->mtu == route_new->mtu) && 
!route_old->failed;
+   (route_old->mtu == route_new->mtu) && (route_old->type 
== route_new->type) &&
+   !route_old->failed;
 
if (node_old) {
if (!(route_old->flags & DEVADDR_EXTERNAL) && 
route_old->enabled && !keep)
@@ -1223,7 +1234,6 @@ interface_ip_init(struct interface *iface)
__interface_ip_init(&iface->proto_ip, iface);
__interface_ip_init(&iface->config_ip, iface);
vlist_init(&iface->host_routes, route_cmp, interface_update_host_route);
-
 }
 
 static void
diff --git a/interface-ip.h b/interface-ip.h
index 93d55ee..a5612e5 100644
--- a/interface-ip.h
+++ b/interface-ip.h
@@ -45,6 +45,9 @@ enum device_addr_flags {
 
/* route is on-link */
DEVROUTE_ONLINK = (1 << 9),
+
+   /* route overrides the default route type */
+   DEVROUTE_TYPE   = (1 << 10),
 };
 
 union if_addr {
@@ -107,6 +110,7 @@ struct device_route {
 
union if_addr nexthop;
int mtu;
+   unsigned int type;
time_t valid_until;
 
/* must be last */
diff --git a/system-dummy.c b/system-dummy.c
index bb94781..f2988f2 100644
--- a/system-dummy.c
+++ b/system-dummy.c
@@ -193,6 +193,12 @@ int system_flush_routes(void)
return 0;
 }
 
+bool system_resolve_rt_type(const char *type, unsigned int *id)
+{
+   *id = 0;
+   return true;
+}
+
 bool system_resolve_rt_table(const char *name, unsigned int *id)
 {
*id = 0;
diff --git a/system-linux.c b/system-linux.c
index 8a07247..5dc0d51 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -164,6 +164,46 @@ create_event_socket(struct event_socket *ev, int protocol,
return true;
 }
 
+static bool
+system_rtn_aton(const char *src, unsigned int *dst)
+{
+   char *e;
+   unsigned int n;
+
+   if (!strcmp(src, "local"))
+   n = RTN_LOCAL;
+   else if (!strcmp(src, "nat"))
+   n = RTN_NAT;
+   else if (!strcmp(src, "broadcast"))
+   n = RTN_BROADCAST;
+   else if (!strcmp(src, "anycast"))
+   n = RTN_ANYCAST;
+   else if (!strcmp(src, "multicast"))
+   n = RTN_MULTICAST;
+   else if (!strcmp(src, "prohibit"))
+   n = RTN_PROHIBIT;
+   else if (!strcmp(src, "unreachable"))
+   n = RTN_UNREACHABLE;
+   else if (!strcmp(src, "blackhole"))
+   n = RTN_BLACKHOLE;
+   else if (!strcmp(src, "xresolve"))
+   n = RTN_XRESOLVE;
+   else if (!strcmp(src, "unicast"))
+   n = RTN_UNICAST;
+   else if (!strcmp(src, "throw"))
+   n = RTN_THROW;
+   else if (!strcmp(src, "failed_policy"))
+   n = RTN_FAILED_POLICY;
+   else {
+   n = strtoul(src, &e, 0);
+   if (!e || *e || e == 

[OpenWrt-Devel] [PATCH 3/5] netifd: Fix ipip6 tunnel memleak in case of tunnel creation failure

2014-06-17 Thread Hans Dedecker

Signed-off-by: Hans Dedecker 
---
 system-linux.c |   44 ++--
 1 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/system-linux.c b/system-linux.c
index 9b5cffa..8a07247 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -1749,8 +1749,12 @@ int system_add_ip_tunnel(const char *name, struct 
blob_attr *attr)
} else if (!strcmp(str, "ipip6")) {
struct nl_msg *nlm = nlmsg_alloc_simple(RTM_NEWLINK,
NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE);
-
struct ifinfomsg ifi = { .ifi_family = AF_UNSPEC };
+   int ret = 0;
+
+   if (!nlm)
+   return -1;
+
nlmsg_append(nlm, &ifi, sizeof(ifi), 0);
nla_put_string(nlm, IFLA_IFNAME, name);
 
@@ -1758,8 +1762,16 @@ int system_add_ip_tunnel(const char *name, struct 
blob_attr *attr)
nla_put_u32(nlm, IFLA_LINK, link);
 
struct nlattr *linkinfo = nla_nest_start(nlm, IFLA_LINKINFO);
+   if (!linkinfo) {
+   ret = -ENOMEM;
+   goto failure;
+   }
nla_put_string(nlm, IFLA_INFO_KIND, "ip6tnl");
struct nlattr *infodata = nla_nest_start(nlm, IFLA_INFO_DATA);
+   if (!infodata) {
+   ret = -ENOMEM;
+   goto failure;
+   }
 
if (link)
nla_put_u32(nlm, IFLA_IPTUN_LINK, link);
@@ -1770,14 +1782,18 @@ int system_add_ip_tunnel(const char *name, struct 
blob_attr *attr)
 
struct in6_addr in6buf;
if ((cur = tb[TUNNEL_ATTR_LOCAL])) {
-   if (inet_pton(AF_INET6, blobmsg_data(cur), &in6buf) < 1)
-   return -EINVAL;
+   if (inet_pton(AF_INET6, blobmsg_data(cur), &in6buf) < 
1) {
+   ret = -EINVAL;
+   goto failure;
+   }
nla_put(nlm, IFLA_IPTUN_LOCAL, sizeof(in6buf), &in6buf);
}
 
if ((cur = tb[TUNNEL_ATTR_REMOTE])) {
-   if (inet_pton(AF_INET6, blobmsg_data(cur), &in6buf) < 1)
-   return -EINVAL;
+   if (inet_pton(AF_INET6, blobmsg_data(cur), &in6buf) < 
1) {
+   ret = -EINVAL;
+   goto failure;
+   }
nla_put(nlm, IFLA_IPTUN_REMOTE, sizeof(in6buf), 
&in6buf);
}
 
@@ -1796,14 +1812,18 @@ int system_add_ip_tunnel(const char *name, struct 
blob_attr *attr)
char ip4buf[16];
 
if (sscanf(blobmsg_get_string(fmr), 
"%47[^/]/%u,%15[^/]/%u,%u,%u",
-   ip6buf, &ip6len, ip4buf, 
&ip4len, &ealen, &offset) < 5)
-   return -EINVAL;
+   ip6buf, &ip6len, ip4buf, 
&ip4len, &ealen, &offset) < 5) {
+   ret = -EINVAL;
+   goto failure;
+   }
 
struct in6_addr ip6prefix;
struct in_addr ip4prefix;
if (inet_pton(AF_INET6, ip6buf, &ip6prefix) != 
1 ||
-   inet_pton(AF_INET, ip4buf, 
&ip4prefix) != 1)
-   return -EINVAL;
+   inet_pton(AF_INET, ip4buf, 
&ip4prefix) != 1) {
+   ret = -EINVAL;
+   goto failure;
+   }
 
struct nlattr *rule = nla_nest_start(nlm, 
++fmrcnt);
 
@@ -1825,7 +1845,11 @@ int system_add_ip_tunnel(const char *name, struct 
blob_attr *attr)
nla_nest_end(nlm, linkinfo);
 
return system_rtnl_call(nlm);
-   } else
+failure:
+   nlmsg_free(nlm);
+   return ret;
+   }
+   else
return -EINVAL;
 
return 0;
-- 
1.7.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel