Re: [OpenWrt-Devel] SHA512/SHA256 hashes truncated/busybox weirdness

2016-01-07 Thread Nikos Mavrogiannopoulos
On Sun, 2016-01-03 at 11:17 -0800, Chris Marchesi wrote:
> Hey!
> 
> I tried to change the default passwd algorithm used by busybox to 
> sha512, but got some strange looking hashes back by passwd after 
> changing.
> They basically had the algorithm and the salt (maybe) squashed, like 
> below.
> $6abCDefGH:(rest of shadow entry here)

That is a uclibc bug. When it didn't support the algorithm it
incorrectly used the DES crypt instead. Most likely the openwrt uclibc
doesn't contain the fix.

https://bugs.busybox.net/show_bug.cgi?id=7808

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


[OpenWrt-Devel] Kudos to Felix (some interesting numbers for ar71xx)

2016-01-07 Thread Daniel Dickinson

Hi all,

I thought I would give you some numbers from my system before and afters 
Felix's changes, since they are such an awesome difference.


First info about the the system:

* 8-core AMD 4.0 GHz FX processor
* 2 x ~500 MB/s SSD in RAID 1 configuration (and it was  good thing too, 
due to a cabling issue with one drive that showed up under load, fixed 
now but it saved my bacon).
* VMWare Workstation 12.0 (because I have had far too many glitching 
guests with Virtualbox but must use VB for work, and only VMWare 
supports running Virtualbox in a nested hypervisor configuration); I've 
had fewer guest glitches with KVM than with VB, but VMWare is better 
with Windows guests (which are still a requirement, despite all the 
hoopla about being able to do away with it).


* Build doesn't include any actual image generation
* Includes SDK & IB
* Includes only a minimal set of packages
* Against unmodified trunk in all cases.
* ar71xx generic with all profiles selected (i.e. not selecting only an 
individual profile)


1) Old Rebuild with no changes for SDK, IB only build (no actual images, 
and minimal package set)

time make -j9 2>&1
real14m7.382s
user46m47.500s
sys 10m30.111s

2) Rebuild with Felix's changes and other trunk changes for SDK, IB only 
build (no actual images, and minimal package set)

time make -j9 2>&1
real7m51.559s
user12m7.056s
sys 2m43.478s

AFAICT the trunk changes only actually affected the rebuild of one 
package I was actually building for t

his test.

3) Rebuild with Felix's changes present but no change from last build 
for SDK, IB only build (no actual images, and minimal package set)

time make -j9 2>&1
real7m25.962s
user11m34.550s
sys 2m17.158s

That's an ~50% reduction in real time, and ~75% reduction in user CPU 
time, with and additional ~80% reduction in system time.  Net CPU time 
goes from ~1 hour to ~14 minutes.


It's pretty darn impressive, I'd say.

Regards,

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


Re: [OpenWrt-Devel] [PATCH 1/1] [DEV-1329] use NTP server received via DHCP

2016-01-07 Thread Bastian Bittorf
* amine ahd  [07.01.2016 10:34]:

the patch is from wrong dir.
please do a 'git format-patch' inside the OpenWrt-dir,
so the modified files are:

package/utils/busybox/Makefile
package/utils/busybox/files/sysntpd
package/utils/busybox/files/sysntpd.hotplug

for the subject: what means "[DEV-1329]"?

> +. /usr/share/libubox/jshn.sh
>  START=98
>  
>  USE_PROCD=1
> @@ -22,12 +24,32 @@ start_service() {
>  
>   [ $enabled = 0 ] && return
>  
> - [ -z "$server" ] && return

please check if any interface is in DHCP-mode
and has a chance to get an NTP, otherwise return. 

> + if [ "$use_dhcp" = 1 ]; then

minor: use OpenWrt-style:
when there is no 'else', just do:

[ "$use_dhcp" = 1 ] && {
...
}

> + if [ -z "$dhcp_ifaces" ]; then
> + dump=$(ubus call network.interface dump)

make 'dump' also 'local'

> +check_int() {

minor: choose better function name.

> + list=$(uci get system.ntp.dhcp_ifaces)
> + if [ -z $list ];
> + then
> + return 0
> + fi

it's shorter:
[ -z "$list" ] && return

> + if [ "${list#*$INTERFACE}" != "$list" ]

this looks strange to me and will IMHO not work
for similar names, e.g. eth0 eth0.1 eth0.2

you want to test, if the upcoming $INTERFACE is part
of allowed interfaces ("system.ntp.dhcp_ifaces"), aren't you?

is_valid_interface()
{
local list="$(uci get system.ntp.dhcp_ifaces)"

case " $list " in
*" $INTERFACE "*)
;;
*)
return 1
;;
esac
}

> + for int in $dhcp_ifaces; do

please you 'iface' or 'interface' not 'int'
but thanks for the patch for now!

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


Re: [OpenWrt-Devel] [PATCH] openvpn: added service_triggers() to init script

2016-01-07 Thread Felix Fietkau
On 2016-01-07 13:03, Nemesis wrote:
> Follow up of #21469
> 
> This patch enables autoreloading openvpn via procd.
> 
> For more information see: https://dev.openwrt.org/ticket/21469
> 
> Signed-off-by: Federico Capoano 
> ---
>  package/network/services/openvpn/files/openvpn.init | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/package/network/services/openvpn/files/openvpn.init
> b/package/network/services/openvpn/files/openvpn.init
The patch is line wrapped and does not apply. Please consider using
git send-email.

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


[OpenWrt-Devel] [PATCH] netifd: Do not add local/source policy rules multiple times

2016-01-07 Thread Kristian Evensen
From: Kristian Evensen 

interface_ip_set_enabled() is usually called two times right after one another,
once to handle config_ip and once to handle proto_ip. As long as
ip->iface->l3_dev.dev is set, the local/source policy rules are updated.

This value is in several cases set on both config_ip and proto_ip, causing the
rules to be added multiple time. The reason is that the kernel does not respect
the NLM_F_* flag for rules. In other words, the rule state has to be managed by
the routing daemon.

Since the local/source policy rules are bound to iface, this commit solves the
problem by adding a flag to interface which stores the current rule state. The
flag follows the enabled-paramter passed to interface_ip_set_enabled(), similar
to route-> and addr->enabled. The flag breaks the alignment of the interface
struct, but based on earlier commits this seems to be ok.

I have tested the patch in different configurations and have not found any
regression.

Signed-off-by: Kristian Evensen 
---
 interface-ip.c | 4 +++-
 interface.h| 1 +
 system-linux.c | 4 +---
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/interface-ip.c b/interface-ip.c
index 1e085bc..b96d98c 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -1289,12 +1289,14 @@ void interface_ip_set_enabled(struct 
interface_ip_settings *ip, bool enabled)
if (!strcmp(a->name, ip->iface->name))
interface_set_prefix_address(a, c, ip->iface, 
enabled);
 
-   if (ip->iface && ip->iface->l3_dev.dev) {
+   if (ip->iface && ip->iface->policy_rules_set != enabled &&
+   ip->iface->l3_dev.dev) {
set_ip_lo_policy(enabled, true, ip->iface);
set_ip_lo_policy(enabled, false, ip->iface);
 
set_ip_source_policy(enabled, true, IPRULE_PRIORITY_REJECT + 
ip->iface->l3_dev.dev->ifindex,
NULL, 0, 0, ip->iface, "failed_policy");
+   ip->iface->policy_rules_set = enabled;
}
 }
 
diff --git a/interface.h b/interface.h
index c2049f1..73a3b55 100644
--- a/interface.h
+++ b/interface.h
@@ -112,6 +112,7 @@ struct interface {
bool link_state;
bool force_link;
bool dynamic;
+   bool policy_rules_set;
 
time_t start_time;
enum interface_state state;
diff --git a/system-linux.c b/system-linux.c
index d3bb64d..2b17764 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -1792,10 +1792,8 @@ static int system_iprule(struct iprule *rule, int cmd)
.rtm_flags = 0,
};
 
-   if (cmd == RTM_NEWRULE) {
+   if (cmd == RTM_NEWRULE)
rtm.rtm_type = RTN_UNICAST;
-   rtm.rtm_flags |= NLM_F_REPLACE | NLM_F_EXCL;
-   }
 
if (rule->invert)
rtm.rtm_flags |= FIB_RULE_INVERT;
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/1] [DEV-1329] use NTP server received via DHCP

2016-01-07 Thread Amine Aouled Hamed
On Thu, Jan 7, 2016 at 2:42 PM, Bastian Bittorf 
wrote:

> when looking at the present code, it
> returns when the static list is empty.
>
> maybe it's a rare condition, but your code
> changes the behavior. for now ignore this
> and polish the rest, lets see what the others say.
>
> bye, bastian
>

AFAIK, this was the default behaviour. I removed it because IMO it is not
the case anymore to exit when we have an empty static list.
If this needs to be changed, please let me know.

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


[OpenWrt-Devel] Atomic/failsafe upgrades?

2016-01-07 Thread Joshua Judson Rosen
I'm trying to decide on a Linux-based OS to use in a project,
and one of the features that I want is failsafe upgrades--
such that failing to run an upgrade procedure to completion
should be non-catastrophic, and automatically recoverable; the
system should always be able to (re)boot into a state
where it can run normally, either in the upgraded state
or in the pre-upgrade state.

One option that I've deal with is to keep two parallel
system installs, upgrade whichever one you're not currently using,
try to boot _that one_ after the upgrade finishes,
and fall back to the last-known-good install
if either the upgrade fails in the middle or the boot into
the preferred install fails. IIRC, there's something like this
available with Yocto; and, if I understand it correctly,
NixOS also does something similar in spirit to this
(though perhaps with a different granularity).

Are there any provisions for doing something like that
with OpenWRT?

-- 
"Don't be afraid to ask (λf.((λx.xx) (λr.f(rr."
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] use NTP server received via DHCP

2016-01-07 Thread Felix Fietkau
On 2015-12-30 14:14, Yousong Zhou wrote:
> Hi,
> 
> On 30 December 2015 at 20:12, Amine Aouled Hamed  wrote:
>>
>> Hi,
>> Can you elaborate more on why you prefer uci state? I am just starting with 
>> OpenWRT and the first thing I found was procd.
>>
> 
> Most of it is really just personal preference.  I prefer uci because
> it can provide more structured access/manipulation of the state, e.g.
> 
>  - disable those ntpservers on interface down
>  - when it comes to ntpservers from multiple dhcp interfaces
>  - the state can be easily checked with uci command if something went wrong
> 
> These can of course also be done with procd data, but uci is already there...
Here's some context for why we stopped using uci state:

Mixing configuration with a state overlay can easily get very messy,
especially when the config changes - it's just too easy for namespace
collisions to creep in.
Cleanup is also difficult when there's no clear separation of which
script is responsible for which part of the state overlay.

Using procd data has the advantange that the state is tied to the
running state of the service. If the service dies or is restarted, its
state is automatically cleaned up too.

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


Re: [OpenWrt-Devel] Atomic/failsafe upgrades?

2016-01-07 Thread Eric Schultz
Joshua,

I've had some similar interest in this topic.  As far as I know, there
isn't anything like this on OpenWrt. There might be some overlap with the
discussion of automatic updates from last week as well.

Eric

On Thu, Jan 7, 2016 at 11:44 AM, Joshua Judson Rosen 
wrote:

> I'm trying to decide on a Linux-based OS to use in a project,
> and one of the features that I want is failsafe upgrades--
> such that failing to run an upgrade procedure to completion
> should be non-catastrophic, and automatically recoverable; the
> system should always be able to (re)boot into a state
> where it can run normally, either in the upgraded state
> or in the pre-upgrade state.
>
> One option that I've deal with is to keep two parallel
> system installs, upgrade whichever one you're not currently using,
> try to boot _that one_ after the upgrade finishes,
> and fall back to the last-known-good install
> if either the upgrade fails in the middle or the boot into
> the preferred install fails. IIRC, there's something like this
> available with Yocto; and, if I understand it correctly,
> NixOS also does something similar in spirit to this
> (though perhaps with a different granularity).
>
> Are there any provisions for doing something like that
> with OpenWRT?
>
> --
> "Don't be afraid to ask (λf.((λx.xx) (λr.f(rr."
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>



-- 
Eric Schultz, Community Manager, prpl Foundation
http://www.prplfoundation.org
eschu...@prplfoundation.org
cell: 920-539-0404
skype: ericschultzwi
@EricPrpl
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/1] use NTP server received via DHCP

2016-01-07 Thread Bastian Bittorf
* amine ahd  [07.01.2016 19:41]:
> ---
>  package/utils/busybox/Makefile |  3 ++
>  package/utils/busybox/files/sysntpd| 28 +++-
>  .../package/utils/busybox/files/sysntpd.hotplug| 53 
> ++

the path for "sysntpd.hotplug" is wrong, it should be:
package/utils/busybox/files/sysntpd.hotplug

> + local dhcp_ifaces="$(uci -q get system.ntp.dhcp_ifaces)"
> + [ "$use_dhcp" = 1 ] && {
> + if [ -z "$dhcp_ifaces" ]; then
> + local dump=$(ubus call network.interface dump)
> + ntpservers=$(jsonfilter -s "$dump" -e 
> '$["interface"][*]["data"]["ntpserver"]')
> + else
> + for iface in $dhcp_ifaces; do
> + local status=$(ubus call network.interface.$int 
> status)

please test if your code really runs.
you have renamed "int" to "iface", but not everywhere

> + [ -n "$ntpserver" ] &&
> + ntpservers="$ntpservers $ntpserver"

here is a '\' at line end missing, is'nt it?

>  service_triggers()
>  {
>   procd_add_reload_trigger "system"
> +
>   procd_add_validation validate_ntp_section
> +
>  }

are these newlines really needed?

> +. /lib/functions.sh
> +. /usr/share/libubox/jshn.sh
> +
> +is_valid_interface() {
> + local list=$(uci get system.ntp.dhcp_ifaces)
> + [ -z "$list" ] && return 0;

the ";" is unneeded

> +
> + case "$list" in
> + *"$INTERFACE"*)
> + return 0

please use the spaces like i wrote:
" $list "
and
*" $INTERFACE "*

> + [ -n "$ntpserver" ] &&
> + dhcp_ntp_servers="dhcp_ntp_servers $ntpserver"

here is also a "\" missing 

please: before sending this patch to the mailinglist, try
to manually apply it to a fresh git-checkout of openwrt.
after applying, test the resulting files with "shellcheck.net".

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


Re: [OpenWrt-Devel] [PATCH 1/1] package/libs/zlib: new package zlib-dev

2016-01-07 Thread Felix Fietkau
On 2016-01-07 21:03, Heinrich Schuchardt wrote:
> The patch adds a new package zlib-dev. It contains all files needed for
> compiling a program using the zlib library:
> 
> /usr/include/zconf.h
> /usr/include/zlib.h
> /usr/lib/libz.a
> /usr/lib/pkgconfig/zlib.pc
> 
> Signed-off-by: Heinrich Schuchardt 
Instead of turning the config item into a menu, please move it to the
top-level "Development" menu, maybe with a submenu "Libraries".

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


[OpenWrt-Devel] [PATCH 1/1] package/libs/zlib: new package zlib-dev

2016-01-07 Thread Heinrich Schuchardt
The patch adds a new package zlib-dev. It contains all files needed for
compiling a program using the zlib library:

/usr/include/zconf.h
/usr/include/zlib.h
/usr/lib/libz.a
/usr/lib/pkgconfig/zlib.pc

Signed-off-by: Heinrich Schuchardt 
---
 package/libs/zlib/Makefile | 32 
 1 file changed, 32 insertions(+)

diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
index 1d7b7b1..5993cbc 100644
--- a/package/libs/zlib/Makefile
+++ b/package/libs/zlib/Makefile
@@ -27,6 +27,24 @@ define Package/zlib
   URL:=http://www.zlib.net/
 endef
 
+define Package/zlib-dev
+  SECTION:=devel
+  CATEGORY:=Development
+  SUBMENU:=Libraries
+  DEPENDS:=zlib
+  TITLE:=Development files for the zlib library
+endef
+
+define Package/zlib/description
+ zlib is a lossless data-compression library.
+ This package includes the shared library.
+endef
+
+define Package/zlib-dev/description
+ zlib is a lossless data-compression library.
+ This package includes the development support files.
+endef
+
 define Build/Configure
(cd $(PKG_BUILD_DIR); \
$(TARGET_CONFIGURE_OPTS) \
@@ -69,4 +87,18 @@ define Package/zlib/install
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so.* $(1)/usr/lib/
 endef
 
+define Package/zlib-dev/install
+   $(INSTALL_DIR) $(1)/usr/include
+   $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/zconf.h \
+ $(1)/usr/include/
+   $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/zlib.h \
+ $(1)/usr/include/
+   $(INSTALL_DIR) $(1)/usr/lib
+   $(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.a $(1)/usr/lib/
+   $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+   $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/zlib.pc \
+ $(1)/usr/lib/pkgconfig/
+endef
+
 $(eval $(call BuildPackage,zlib))
+$(eval $(call BuildPackage,zlib-dev))
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Atomic/failsafe upgrades?

2016-01-07 Thread Luiz Angelo Daros de Luca
Hi,

I have a client that just asked for this. As their router uses grub, its
script if enough for the fallback logic. I implemented a POC and it worked
perfectly. There is no watchdog integration so the reboot is manually done
when the new firmware fails.

I'm just waiting for them to give me a go in order to implement a complete
solution. I'll post to the list when I get a working patch.

The basic idea is to have two rootfs (and two rootfs data) in flash. I
embed the kernel into squashfs, making rootfs self contained (as grub2 can
read squashfs). If I give to sysupgrade a squashfs image, it writes
alternately into the rootfs areas. It tries to boot the new flash once
(like grub-once). If it works, mark it as permanent. If not, just reboot
and the previous flash will be used.

Now, when I give a full xxx.img file, it overwrite all the system just like
the normal openwrt image does (something like proprietary xxx_boot.img). Of
course, this type of boot firmware does not have the fallback.

Regards,

Em qui, 7 de jan de 2016 18:16, Arthur Davis  escreveu:

> With failsafe upgrades, there always has to be "the thing that notices"
> when something goes wrong. With a wholesale upgrade, OpenWrt can't be that
> thing. The bootloader is probably the best candidate.
>
> Also, I've worked on projects that used a separate supervisory processor
> that was able to dictate the boot image. In one case, it was a very
> powerful processor that had its own jobs in the system. In another case, it
> was very small and just watched out for system health. One way to dictate
> the boot image is to have the OpenWrt system ask via tftp, but there are
> probably other possibilities depending on your system. (And this probably
> doesn't really apply unless you are able to specify some fundamental bits
> of the hardware.)
>
> Lastly, there is OpenWrt's failsafe mode which doesn't solve all of your
> concerns, but it should be noted:
> https://wiki.openwrt.org/doc/howto/generic.failsafe
>
> Arthur
>
>
> On Thu, Jan 7, 2016 at 11:48 AM, Eric Schultz  > wrote:
>
>> Joshua,
>>
>> I've had some similar interest in this topic.  As far as I know, there
>> isn't anything like this on OpenWrt. There might be some overlap with the
>> discussion of automatic updates from last week as well.
>>
>> Eric
>>
>> On Thu, Jan 7, 2016 at 11:44 AM, Joshua Judson Rosen <
>> jro...@harvestai.com> wrote:
>>
>>> I'm trying to decide on a Linux-based OS to use in a project,
>>> and one of the features that I want is failsafe upgrades--
>>> such that failing to run an upgrade procedure to completion
>>> should be non-catastrophic, and automatically recoverable; the
>>> system should always be able to (re)boot into a state
>>> where it can run normally, either in the upgraded state
>>> or in the pre-upgrade state.
>>>
>>> One option that I've deal with is to keep two parallel
>>> system installs, upgrade whichever one you're not currently using,
>>> try to boot _that one_ after the upgrade finishes,
>>> and fall back to the last-known-good install
>>> if either the upgrade fails in the middle or the boot into
>>> the preferred install fails. IIRC, there's something like this
>>> available with Yocto; and, if I understand it correctly,
>>> NixOS also does something similar in spirit to this
>>> (though perhaps with a different granularity).
>>>
>>> Are there any provisions for doing something like that
>>> with OpenWRT?
>>>
>>> --
>>> "Don't be afraid to ask (λf.((λx.xx) (λr.f(rr."
>>> ___
>>> openwrt-devel mailing list
>>> openwrt-devel@lists.openwrt.org
>>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>>>
>>
>>
>>
>> --
>> Eric Schultz, Community Manager, prpl Foundation
>> http://www.prplfoundation.org
>> eschu...@prplfoundation.org
>> cell: 920-539-0404
>> skype: ericschultzwi
>> @EricPrpl
>>
>> ___
>> 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
>
-- 

Luiz Angelo Daros de Luca
luizl...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Need help with Makefile error *** missing separator

2016-01-07 Thread Andy Wong
It works.Thanks jow for the details.
At 2016-01-05 18:45:47, "Jo-Philipp Wich"  wrote:
>Each line in Make is started in a new shell. Your added lines are 
>executed as (simplified):
>
>bash -c 'if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then'
>bash -c '$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n'
>bash -c '$(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo 
>$(1)/usr/lib/lua/luci/i18n'
>bash -c 'fi'
>
>The first "if" command is invalid because it is not terminated 
>("unexpected end of file") and the single "fi" command in the end is 
>invalid syntax as well (preceding if ... then missing).
>
>You need to join your four lines into a single statement by escaping 
>the newline with a backslash and by terminating statements with a 
>semicolon:
>
>>  if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then \
>>  $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n; \
>>  $(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo 
>> $(1)/usr/lib/lua/luci/i18n; \
>>  fi
>
>Which will result in (simplified)
>
>bash -c 'if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then $(INSTALL_DIR) 
>$(1)/usr/lib/lua/luci/i18n; $(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo 
>$(1)/usr/lib/lua/luci/i18n; fi'
>
>
>~ Jow
>
>On 01/05/2016 10:41 AM, Andy Wong wrote:
>> Hi.I not quite understand.I've change the install part as below:
>> 
>> define Package/openwrt-dist-luci/install
>> #!/bin/sh
>> $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
>> $(INSTALL_DATA) ./files/luci/controller/$(2).lua
>> $(1)/usr/lib/lua/luci/controller/$(2).lua
>> $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
>> $(INSTALL_DATA) ./files/luci/model/cbi/$(2).lua
>> $(1)/usr/lib/lua/luci/model/cbi/$(2).lua
>> $(INSTALL_DIR) $(1)/etc/uci-defaults
>> $(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-$(2)
>> $(1)/etc/uci-defaults/luci-$(2)
>> *if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then*
>> *$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n*
>> *$(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo
>> $(1)/usr/lib/lua/luci/i18n*
>> *fi*
>> exit 0
>> endef
>> 
>> Notice the if then course.
>> 
>> Here is the error now.
>> 
>> if [ -f "./files/luci/i18n/chinadns.zh-cn.lmo" ]; then install -d -m0755
>> /home/Openwrt/witi-openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openwrt-dist-luci/ipkg-all/luci-app-chinadns/usr/lib/lua/luci/i18n
>> install -m0644 ./files/luci/i18n/chinadns.zh-cn.lmo
>> /home/Openwrt/witi-openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openwrt-dist-luci/ipkg-all/luci-app-chinadns/usr/lib/lua/luci/i18n
>> fi
>> bash: -c: line 1: syntax error: unexpected end of file
>> make[2]: ***
>> [/home/Openwrt/witi-openwrt/bin/ramips/packages/base/luci-app-chinadns_1.3.8-1_all.ipk]
>> Error 1
>> make[2]: Leaving directory
>> `/home/Openwrt/witi-openwrt/package/my_package/openwrt-dist-luci'
>> make[1]: *** [package/my_package/openwrt-dist-luci/compile] Error 2
>> make[1]: Leaving directory `/homeOpenwrt/witi-openwrt'
>> make: *** [package/openwrt-dist-luci/compile] 错误 2
>> 
>> 
>> 
>> 
>> At 2016-01-04 22:28:36, "Luiz Angelo Daros de Luca" 
>> wrote:
>> 
>> Andy,
>> 
>> Make runs one line per time. Make the "if" inline or backslash each
>> newline (adding semicolon when needed)
>> 
>> Regards
>> 
>> 
>> Em seg, 4 de jan de 2016 11:56, Andy Wong > > escreveu:
>> 
>> 
>> For no misunderstanding.Here is the error now
>> http://pastebin.com/t4Rb08kA
>> 
>> 
>> 
>> 
>> 
>> 
>> 在 2016-01-04 21:18:14,"Andy Wong" > > 写道:
>> >Thanks.I have indented like this:define 
>> Package/openwrt-dist-luci/install#!/bin/sh   $(INSTALL_DIR) 
>> $(1)/usr/lib/lua/luci/controller$(INSTALL_DATA) 
>> ./files/luci/controller/$(2).lua 
>> $(1)/usr/lib/lua/luci/controller/$(2).lua $(INSTALL_DIR) 
>> $(1)/usr/lib/lua/luci/model/cbi $(INSTALL_DATA) 
>> ./files/luci/model/cbi/$(2).lua 
>> $(1)/usr/lib/lua/luci/model/cbi/$(2).lua   $(INSTALL_DIR) 
>> $(1)/etc/uci-defaults   $(INSTALL_BIN) 
>> ./files/root/etc/uci-defaults/luci-$(2) $(1)/etc/uci-defaults/luci-$(2) 
>> if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then $(INSTALL_DIR) 
>> $(1)/usr/lib/lua/luci/i18n  $(INSTALL_DATA) 
>> ./files/luci/i18n/$(2).zh-cn.lmo $(1)/usr/lib/lua/luci/i18n
>> fiendefBut another error 
>> appears:enwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openwrt-dist-luci/ipkg-all/luci-app-chinadns/etc/uci-defaults/luci-chinadnsif
>>  [ -f "./files/luci/i18n/chinadns.zh-cn.lmo" ]; thenbash: -c: line 1: 
>> syntax e
> r
>ror: unexpected end of filemake[2]: *** 
>[/home/Openwrt/witi-openwrt/bin/ramips/packages/base/luci-app-chinadns_1.3.8-1_all.ipk]
> Error 1make[2]: Leaving directory 
>`/home/Openwrt/witi-openwrt/package/my_package/openwrt-dist-luci'make[1]: 
>*** [package/my_package/openwrt-dist-luci/compile] Error 2make[1]: 
>Leaving directory `/home/Openwrt/witi-openwrt'make: *** 
>[package/openwrt-dist-luci/compile] 错误 2My 

[OpenWrt-Devel] [PATCH] ar71xx: check for stuck DMA on AR724x & fix sirq storm after recovery

2016-01-07 Thread Conn O'Griofa

Hi,

I'm proposing the following patch to resolve ticket #18922 fully.

With the current master revision, when a tx timeout condition occurs, the 
interface recovers successfully, but a soft irq storm occurs (causing ksoftirqd 
to peg the CPU, due to this goto being called without end: 
https://github.com/openwrt-mirror/openwrt/blob/master/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c#L1073
 ). Forcing the tx and rx rings to be cleared and re-inited in 
ag71xx_restart_work_func seems to avoid the sirq storm, but I'd appreciate 
feedback on whether there's a more effective workaround.

Additionally, ag71xx_check_dma_stuck *does* successfully detect the stuck DMA 
condition on AR7241 (TR-WL842ND v1), so enabling the check for this chipset series 
ensures a link adjust occurs *before* an actual tx timeout is detected. This avoids 
the brief network interruption that normally occurs during the DMA stuck -> tx 
timeout -> link adjust condition.

Conn

P.S. The sirq storm also occurs when ag71xx_check_dma_stuck is utilized on this 
chipset to avoid the tx timeout condition, so it appears that both changes are 
necessary (or at least, a better way to solve the sirq storm needs to be 
discovered).

diff --git 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 31b38d7..8959701 100644
--- 
a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -183,6 +183,8 @@ static void ag71xx_ring_tx_init(struct ag71xx *ag)
ring->curr = 0;
ring->dirty = 0;
netdev_reset_queue(ag->dev);
+
+   ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->tx_ring.descs_dma);
 }
 
 static void ag71xx_ring_rx_clean(struct ag71xx *ag)

@@ -272,6 +274,8 @@ static int ag71xx_ring_rx_init(struct ag71xx *ag)
ring->curr = 0;
ring->dirty = 0;
 
+	ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->rx_ring.descs_dma);

+
return ret;
 }
 
@@ -652,9 +656,6 @@ static int ag71xx_open(struct net_device *dev)

netif_carrier_off(dev);
ag71xx_phy_start(ag);
 
-	ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->tx_ring.descs_dma);

-   ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->rx_ring.descs_dma);
-
ag71xx_hw_set_macaddr(ag, dev->dev_addr);
 
 	netif_start_queue(dev);

@@ -873,6 +874,8 @@ static void ag71xx_restart_work_func(struct work_struct 
*work)
if (ag71xx_get_pdata(ag)->is_ar724x) {
ag->link = 0;
ag71xx_link_adjust(ag);
+   ag71xx_rings_cleanup(ag);
+   ag71xx_rings_init(ag);
return;
}
 
@@ -919,7 +922,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)

struct sk_buff *skb = ring->buf[i].skb;
 
 		if (!flush && !ag71xx_desc_empty(desc)) {

-   if (pdata->is_ar7240 &&
+   if (pdata->is_ar724x &&
ag71xx_check_dma_stuck(ag, ring->buf[i].timestamp))
schedule_work(&ag->restart_work);
break;
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel