[OpenWrt-Devel] [RFC] netifd: Avoid concurrent calls to wifi up/down

2013-10-11 Thread Helmut Schaa
Multiple wifi up/down invocations can conflict badly with each other
resulting in a somehow broken wifi setup.

This can be triggered by calling /etc/init.d/network reload quickly
after netifd started up (before the sleep 5 has finished).

This is a first try to synchronize the usage of wifi up/down.

Signed-off-by: Helmut Schaa helmut.sc...@googlemail.com
---

Sending as RFC since I consider this an ugly hack and somebody else might have 
a better idea.
Helmut


 .../network/config/netifd/files/etc/init.d/network |   23 
 1 file changed, 23 insertions(+)

diff --git a/package/network/config/netifd/files/etc/init.d/network 
b/package/network/config/netifd/files/etc/init.d/network
index 8031802..5c977a8 100755
--- a/package/network/config/netifd/files/etc/init.d/network
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -5,6 +5,15 @@ STOP=90
 
 USE_PROCD=1
 
+wait_lock() {
+   lock /var/run/network.lock
+   trap 'lock -u /var/run/network.lock' EXIT
+}
+
+unlock() {
+   lock -u /var/run/network.lock
+}
+
 start_service() {
[ -e /proc/sys/kernel/core_pattern ]  {
ulimit -c unlimited
@@ -18,12 +27,22 @@ start_service() {
 
 reload_service() {
ubus call network reload
+   
+   # don't run multiple wifi commands in parallel
+   wait_lock
+
/sbin/wifi down
/sbin/wifi up
+
+   unlock
 }
 
 stop_service() {
+   wait_lock
+
/sbin/wifi down
+
+   unlock
 }
 
 service_running() {
@@ -32,10 +51,14 @@ service_running() {
include /lib/network
setup_switch
 
+   wait_lock
+
sleep 5
 
/sbin/wifi down
/sbin/wifi up
+
+   unlock
 }
 
 service_triggers()
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH][ar71xx] Add support for BHU Networks BXU2000n-2 A1

2013-10-11 Thread yangbo
BXU2000n-2 A1 is a BHU Networks WLAN board, use ar9341 chip.

Signed-off-by: Terry Yang yan...@bhunetworks.com

Index: trunk/target/linux/ar71xx/files/arch/mips/ath79/mach-bhu-bxu2000n2-a.c
===
--- trunk/target/linux/ar71xx/files/arch/mips/ath79/mach-bhu-bxu2000n2-a.c  
(revision 0)
+++ trunk/target/linux/ar71xx/files/arch/mips/ath79/mach-bhu-bxu2000n2-a.c  
(revision 0)
@@ -0,0 +1,118 @@
+/*
+ *  BHU BXU2000n-2 A1 board support
+ *
+ *  Copyright (C) 2013 Terry Yang yan...@bhunetworks.com
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include linux/gpio.h
+#include linux/platform_device.h
+
+#include asm/mach-ath79/ath79.h
+#include asm/mach-ath79/ar71xx_regs.h
+
+#include common.h
+#include dev-eth.h
+#include dev-gpio-buttons.h
+#include dev-leds-gpio.h
+#include dev-m25p80.h
+#include dev-usb.h
+#include dev-wmac.h
+#include machtypes.h
+
+#define BHU_BXU2000N2_A1_GPIO_LED_WLAN 13
+#define BHU_BXU2000N2_A1_GPIO_LED_WAN  19
+#define BHU_BXU2000N2_A1_GPIO_LED_LAN  21
+#define BHU_BXU2000N2_A1_GPIO_LED_SYSTEM   14
+
+#define BHU_BXU2000N2_A1_GPIO_BTN_RESET17
+
+#define BHU_BXU2000N2_KEYS_POLL_INTERVAL   20  /* msecs */
+#define BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL (3 * 
BHU_BXU2000N2_KEYS_POLL_INTERVAL)
+
+static const char *bhu_bxu2000n2_part_probes[] = {
+   cmdlinepart,
+   NULL,
+};
+
+static struct flash_platform_data bhu_bxu2000n2_flash_data = {
+   .part_probes= bhu_bxu2000n2_part_probes,
+};
+
+static struct gpio_led bhu_bxu2000n2_a1_leds_gpio[] __initdata = {
+   {
+   .name   = bhu:green:status,
+   .gpio   = BHU_BXU2000N2_A1_GPIO_LED_SYSTEM,
+   .active_low = 1,
+   }, {
+   .name   = bhu:green:lan,
+   .gpio   = BHU_BXU2000N2_A1_GPIO_LED_LAN,
+   .active_low = 1,
+   }, {
+   .name   = bhu:green:wan,
+   .gpio   = BHU_BXU2000N2_A1_GPIO_LED_WAN,
+   .active_low = 1,
+   }, {
+   .name   = bhu:green:wlan,
+   .gpio   = BHU_BXU2000N2_A1_GPIO_LED_WLAN,
+   .active_low = 1,
+   },
+};
+
+static struct gpio_keys_button bhu_bxu2000n2_a1_gpio_keys[] __initdata = {
+   {
+   .desc   = Reset button,
+   .type   = EV_KEY,
+   .code   = KEY_RESTART,
+   .debounce_interval = BHU_BXU2000N2_KEYS_DEBOUNCE_INTERVAL,
+   .gpio   = BHU_BXU2000N2_A1_GPIO_BTN_RESET,
+   .active_low = 1,
+   }
+};
+
+static void __init bhu_ap123_setup(void)
+{
+   u8 *mac = (u8 *) KSEG1ADDR(0x1fff);
+   u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
+
+   ath79_register_m25p80(bhu_bxu2000n2_flash_data);
+
+   ath79_register_mdio(1, 0x0);
+
+   ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+   ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
+
+   /* GMAC0 is connected to the PHY4 of the internal switch */
+   ath79_switch_data.phy4_mii_en = 1;
+   ath79_switch_data.phy_poll_mask = BIT(4);
+   ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+   ath79_eth0_data.phy_mask = BIT(4);
+   ath79_eth0_data.mii_bus_dev = ath79_mdio1_device.dev;
+   ath79_register_eth(0);
+
+   /* GMAC1 is connected to the internal switch. Only use PHY3 */
+   ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+   ath79_eth1_data.phy_mask = BIT(3);
+   ath79_register_eth(1);
+
+   ath79_register_wmac(ee, ee+2);
+}
+
+static void __init bhu_bxu2000n2_a1_setup(void)
+{
+   bhu_ap123_setup();
+
+   ath79_register_leds_gpio(-1, ARRAY_SIZE(bhu_bxu2000n2_a1_leds_gpio),
+bhu_bxu2000n2_a1_leds_gpio);
+
+   ath79_register_gpio_keys_polled(1, BHU_BXU2000N2_KEYS_POLL_INTERVAL,
+   ARRAY_SIZE(bhu_bxu2000n2_a1_gpio_keys),
+   bhu_bxu2000n2_a1_gpio_keys);
+}
+
+MIPS_MACHINE(ATH79_MACH_BHU_BXU2000N2_A1, BXU2000n-2-A1, BHU BXU2000n-2 
rev. A1,
+bhu_bxu2000n2_a1_setup);
+
Index: trunk/target/linux/ar71xx/image/Makefile
===
--- trunk/target/linux/ar71xx/image/Makefile(revision 38362)
+++ trunk/target/linux/ar71xx/image/Makefile(working copy)
@@ -201,6 +201,7 @@
 
wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata),512k(pot),2048k(language),512k(config),3072k(traffic_meter),1152k(kernel),24448k(rootfs),25600k@0x6c(firmware),256k(caldata_backup),-(reserved)
 

Re: [OpenWrt-Devel] [PATCH 4/7] pptpd: Add uci configuration for PPTPD.

2013-10-11 Thread Bruno Randolf

On 10/11/2013 01:24 AM, Yousong Zhou wrote:

To make `enabled 0` a working option, it should be something like

 setup_config pptpd  start_pptpd


Thanks, will fix and resend the patch for trunk.

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


Re: [OpenWrt-Devel] GPIO and pinctrl problem

2013-10-11 Thread Gerhard Bertelsmann
Am Fr, 11.10.2013, 02:59, schrieb Jiapeng Li:
 Which version of trunk do you use? After i downgrade to r38025, all things
 work fine.

Thanks for your response.
I'm using 38333 at the moment. I have opened a ticket: #14309
It seems that some glue code between gpio api and pinctrl is missing.
Hopefully John Crispin will fix it.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/6] Patches for trunk packages

2013-10-11 Thread Bruno Randolf
Similar to my previous series for AA, now rebased to trunk...

Bruno Randolf (6):
  libgphoto2 depends on libusb-compat, not libusb-1.0
  ddns-scripts: add init script
  pptpd: Add uci configuration for PPTPD.
  pptpd: remove IP in options.pptp
  isc-dhcp: dhcrelay: Add more UCI options
  isc-dhcp: dhcrelay: Add RFC3527 link selection sub-option

 libs/libgphoto2/Makefile   |   2 +-
 net/ddns-scripts/Makefile  |   2 +
 net/ddns-scripts/files/etc/init.d/ddns |  12 +++
 net/isc-dhcp/Makefile  |   8 ++
 net/isc-dhcp/files/dhcrelay4.init  |  47 --
 net/isc-dhcp/files/etc/config/dhcrelay |  27 --
 .../patches/100-relay-rfc3527-link-selection.patch | 100 +
 net/pptpd/Makefile |   3 +
 net/pptpd/files/options.pptpd  |   1 -
 net/pptpd/files/pptpd.init |  40 -
 net/pptpd/files/pptpd.uciconf  |   8 ++
 11 files changed, 235 insertions(+), 15 deletions(-)
 create mode 100644 net/ddns-scripts/files/etc/init.d/ddns
 create mode 100644 net/isc-dhcp/patches/100-relay-rfc3527-link-selection.patch
 create mode 100644 net/pptpd/files/pptpd.uciconf

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


[OpenWrt-Devel] [PATCH 2/6] ddns-scripts: add init script

2013-10-11 Thread Bruno Randolf
Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/ddns-scripts/Makefile  |  2 ++
 net/ddns-scripts/files/etc/init.d/ddns | 12 
 2 files changed, 14 insertions(+)
 create mode 100644 net/ddns-scripts/files/etc/init.d/ddns

diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile
index 651c623..0e9f0f3 100644
--- a/net/ddns-scripts/Makefile
+++ b/net/ddns-scripts/Makefile
@@ -37,6 +37,8 @@ endef
 define Package/ddns-scripts/install
$(INSTALL_DIR) $(1)
$(CP) ./files/* $(1)/
+   $(INSTALL_DIR) $(1)/etc/init.d
+   $(INSTALL_BIN) ./files/etc/init.d/ddns $(1)/etc/init.d/
 endef
 
 $(eval $(call BuildPackage,ddns-scripts))
diff --git a/net/ddns-scripts/files/etc/init.d/ddns 
b/net/ddns-scripts/files/etc/init.d/ddns
new file mode 100644
index 000..3171d5a
--- /dev/null
+++ b/net/ddns-scripts/files/etc/init.d/ddns
@@ -0,0 +1,12 @@
+#!/bin/sh /etc/rc.common
+START=95
+
+start() {
+   . /usr/lib/ddns/dynamic_dns_functions.sh
+   start_daemon_for_all_ddns_sections
+}
+
+stop() {
+   killall -9 dynamic_dns_updater.sh
+}
+
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/6] pptpd: Add uci configuration for PPTPD.

2013-10-11 Thread Bruno Randolf
Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/pptpd/Makefile|  3 +++
 net/pptpd/files/pptpd.init| 40 ++--
 net/pptpd/files/pptpd.uciconf |  8 
 3 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 net/pptpd/files/pptpd.uciconf

diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
index e79e0a7..0a2f642 100644
--- a/net/pptpd/Makefile
+++ b/net/pptpd/Makefile
@@ -41,6 +41,7 @@ MAKE_FLAGS += \
 define Package/pptpd/conffiles
 /etc/pptpd.conf
 /etc/ppp/options.pptpd
+/etc/config/pptpd
 endef
 
 define Package/pptpd/install
@@ -58,6 +59,8 @@ define Package/pptpd/install
$(INSTALL_BIN) ./files/pptpd.init $(1)/etc/init.d/pptpd
$(INSTALL_DIR) $(1)/etc/ppp
$(INSTALL_DATA) ./files/options.pptpd $(1)/etc/ppp/
+   $(INSTALL_DIR) $(1)/etc/config
+   $(INSTALL_DATA) ./files/pptpd.uciconf $(1)/etc/config/pptpd
 endef
 
 $(eval $(call BuildPackage,pptpd))
diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
index a74973c..79c0ab6 100644
--- a/net/pptpd/files/pptpd.init
+++ b/net/pptpd/files/pptpd.init
@@ -6,14 +6,50 @@ BIN=pptpd
 DEFAULT=/etc/default/$BIN
 RUN_D=/var/run
 PID_F=$RUN_D/$BIN.pid
+CONFIG=/tmp/pptpd.conf
+CHAP_SECRETS=/etc/ppp/chap-secrets
 
-start() {
+setup_user() {
+   local section=$1
+
+   config_get user $section user
+   config_get passwd $section passwd
+   [ -n $user ] || return 0
+   [ -n $passwd ] || return 0
+
+   echo $user pptp-server $passwd *  $CHAP_SECRETS
+}
+
+setup_config() {
+   local section=$1
+
+   config_get enabled $section enabled
+   [ $enabled -eq 0 ]  return 1
+
+   cp /etc/pptpd.conf $CONFIG
+
+   config_get localip $section localip
+   config_get remoteip $section remoteip
+   [ -n $localip ]  echo localip  $localip  $CONFIG
+   [ -n $remoteip ]  echo remoteip  $remoteip  $CONFIG
+   return 0
+}
+
+start_pptpd() {
[ -f $DEFAULT ]  . $DEFAULT
mkdir -p $RUN_D
for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; 
do
insmod $m /dev/null 21
done
-   $BIN $OPTIONS
+   $BIN $OPTIONS -c $CONFIG
+}
+
+start() {
+   config_load pptpd
+   setup_config pptpd || return
+   [ -e $CHAP_SECRETS ]  rm -f $CHAP_SECRETS
+   config_foreach setup_user key
+   start_pptpd
 }
 
 stop() {
diff --git a/net/pptpd/files/pptpd.uciconf b/net/pptpd/files/pptpd.uciconf
new file mode 100644
index 000..66cf0be
--- /dev/null
+++ b/net/pptpd/files/pptpd.uciconf
@@ -0,0 +1,8 @@
+config service 'pptpd'
+   option 'enabled' '0'
+   option 'localip' '192.168.0.1'
+   option 'remoteip' '192.168.0.20-30'
+
+config 'key'
+   option 'user' 'youruser'
+   option 'passwd' 'yourpass'
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 4/6] pptpd: remove IP in options.pptp

2013-10-11 Thread Bruno Randolf
ppp has obsoleted this option (as of v2.4.3-7) according to
http://wiki.openwrt.org/doc/howto/vpn.server.pptpd

Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/pptpd/files/options.pptpd | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/pptpd/files/options.pptpd b/net/pptpd/files/options.pptpd
index 5dd2daf..f73eeea 100644
--- a/net/pptpd/files/options.pptpd
+++ b/net/pptpd/files/options.pptpd
@@ -1,6 +1,5 @@
 #debug
 #logfile /tmp/pptp-server.log
-172.16.1.1:
 auth
 name pptp-server
 lcp-echo-failure 3
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/6] libgphoto2 depends on libusb-compat, not libusb-1.0

2013-10-11 Thread Bruno Randolf
Signed-off-by: Bruno Randolf b...@einfach.org
---
 libs/libgphoto2/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/libgphoto2/Makefile b/libs/libgphoto2/Makefile
index cc45ece..bf4f55f 100644
--- a/libs/libgphoto2/Makefile
+++ b/libs/libgphoto2/Makefile
@@ -37,7 +37,7 @@ endef
 
 define Package/libgphoto2-drivers
   $(call Package/libgphoto2/Default)
-  DEPENDS:=libgphoto2 +libusb-1.0 +libgd
+  DEPENDS:=libgphoto2 +libusb-compat +libgd
   TITLE:=Gphoto2 drivers for various cameras
 endef
 
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 5/6] isc-dhcp: dhcrelay: Add more UCI options

2013-10-11 Thread Bruno Randolf
Add more options to dhcrelay UCI and init script:

- enabled
- interfaces: Listen interfaces
- relay_mode: What to do about packets that already have a relay option

Also mark /etc/config/dhcrelay as conffile

Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/isc-dhcp/Makefile  |  8 +++
 net/isc-dhcp/files/dhcrelay4.init  | 39 --
 net/isc-dhcp/files/etc/config/dhcrelay | 24 -
 3 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/net/isc-dhcp/Makefile b/net/isc-dhcp/Makefile
index aa27aca..5e5471f 100644
--- a/net/isc-dhcp/Makefile
+++ b/net/isc-dhcp/Makefile
@@ -55,11 +55,19 @@ $(call Package/isc-dhcp-relay-ipv6/description)
  This package is compiled with IPv4 support only.
 endef
 
+define Package/isc-dhcp-relay-ipv4/conffiles
+/etc/config/dhcrelay
+endef
+
 define Package/isc-dhcp-relay-ipv6/description
 $(call Package/isc-dhcp-relay/description)
  This package is compiled with IPv4 and IPv6 support.
 endef
 
+define Package/isc-dhcp-relay-ipv6/conffiles
+/etc/config/dhcrelay
+endef
+
 define Package/isc-dhcp-client-ipv4
   $(call Package/isc-dhcp/Default)
   TITLE+= client (without IPv6)
diff --git a/net/isc-dhcp/files/dhcrelay4.init 
b/net/isc-dhcp/files/dhcrelay4.init
index 70905cf..0f87b37 100644
--- a/net/isc-dhcp/files/dhcrelay4.init
+++ b/net/isc-dhcp/files/dhcrelay4.init
@@ -8,15 +8,42 @@ SERVICE_PID_FILE=/var/run/dhcrelay4.pid
 SERVICE_USE_PID=1
 
 start() {
-local relay_dhcpserver
+   include /lib/network
+   scan_interfaces
+   config_load dhcrelay
 
-config_load dhcrelay
-config_get relay_dhcpserver ipv4 dhcpserver
+   local args=
 
-service_start /usr/sbin/dhcrelay -4 -q \
--pf $SERVICE_PID_FILE $relay_dhcpserver
+   local enabled
+   config_get_bool enabled ipv4 enabled 0
+   [ $enabled -eq 0 ]  return 0
+
+   # listen interfaces
+   local interfaces
+   config_get interfaces ipv4 interfaces
+   if [ -n $interfaces ]; then
+   for net in $interfaces; do
+   local ifname
+   config_get ifname $net ifname
+   [ -n $ifname ]  append args -i $ifname
+   done
+   fi
+
+   # relay mode
+   local relay_mode
+   config_get relay_mode ipv4 relay_mode
+   [ -n $relay_mode ]  append args -m $relay_mode
+
+   # dhcp server address
+   local server
+   config_get server ipv4 dhcpserver
+   [ -n $server ] || return 0
+   append args $server
+
+   service_start /usr/sbin/dhcrelay -4 -q \
+   -pf $SERVICE_PID_FILE $args
 }
 
 stop() {
-service_stop /usr/sbin/dhcrelay
+   service_stop /usr/sbin/dhcrelay
 }
diff --git a/net/isc-dhcp/files/etc/config/dhcrelay 
b/net/isc-dhcp/files/etc/config/dhcrelay
index 5fde239..1b89782 100644
--- a/net/isc-dhcp/files/etc/config/dhcrelay
+++ b/net/isc-dhcp/files/etc/config/dhcrelay
@@ -1,10 +1,24 @@
 
 config dhcrelay ipv4
-option dhcpserver '192.0.2.10'
+   option 'enabled' '0'
+
+   # IP address of the server
+   option 'dhcpserver' '192.0.2.10'
+
+   # network interfaces to listen on (e.g. lan or wan)
+   option 'interfaces' ''
+
+   # What to do about packets that already have a relay option:
+   # 'append': Forward and append our own relay option
+   # 'replace': Forward, but replace theirs with ours (default)
+   # 'forward': Forward without changes
+   # 'discard': Don't forward
+   option 'relay_mode' ''
+
 
 config dhcrelay ipv6
-#option dhcpserver '2001:db8:1::1'
-option upper 'eth1'
-list lower 'eth0.2'
-list lower 'eth0.3'
+#  option dhcpserver '2001:db8:1::1'
+   option upper 'eth1'
+   list lower 'eth0.2'
+   list lower 'eth0.3'
 
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 6/6] isc-dhcp: dhcrelay: Add RFC3527 link selection sub-option

2013-10-11 Thread Bruno Randolf
RFC3527 link selection sub-option is used to select the uplink interface of
dhcrelay in cases where the DHCP server does not know how to reach the dhcrelay
based on the DHCP range. This can happen in weird network configurations like
Mesh networks.

Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/isc-dhcp/files/dhcrelay4.init  |   8 ++
 net/isc-dhcp/files/etc/config/dhcrelay |   3 +
 .../patches/100-relay-rfc3527-link-selection.patch | 100 +
 3 files changed, 111 insertions(+)
 create mode 100644 net/isc-dhcp/patches/100-relay-rfc3527-link-selection.patch

diff --git a/net/isc-dhcp/files/dhcrelay4.init 
b/net/isc-dhcp/files/dhcrelay4.init
index 0f87b37..d03722f 100644
--- a/net/isc-dhcp/files/dhcrelay4.init
+++ b/net/isc-dhcp/files/dhcrelay4.init
@@ -29,6 +29,14 @@ start() {
done
fi
 
+   # link selection sub-option (RFC3527)
+   local link_selection
+   config_get link_selection ipv4 link_selection
+   if [ -n $link_selection ]; then
+   config_get ifname $link_selection ifname
+   append args -l $ifname
+   fi
+
# relay mode
local relay_mode
config_get relay_mode ipv4 relay_mode
diff --git a/net/isc-dhcp/files/etc/config/dhcrelay 
b/net/isc-dhcp/files/etc/config/dhcrelay
index 1b89782..b3b53b5 100644
--- a/net/isc-dhcp/files/etc/config/dhcrelay
+++ b/net/isc-dhcp/files/etc/config/dhcrelay
@@ -15,6 +15,9 @@ config dhcrelay ipv4
# 'discard': Don't forward
option 'relay_mode' ''
 
+   # enable RFC3527 link selection sub-option and use the IP address of
+   # the specified network interface as uplink IP address (e.g. wan)
+   option 'link_selection' ''
 
 config dhcrelay ipv6
 #  option dhcpserver '2001:db8:1::1'
diff --git a/net/isc-dhcp/patches/100-relay-rfc3527-link-selection.patch 
b/net/isc-dhcp/patches/100-relay-rfc3527-link-selection.patch
new file mode 100644
index 000..1f593ee
--- /dev/null
+++ b/net/isc-dhcp/patches/100-relay-rfc3527-link-selection.patch
@@ -0,0 +1,100 @@
+--- a/relay/dhcrelay.c
 b/relay/dhcrelay.c
+@@ -65,6 +65,7 @@ int server_packets_relayed = 0;  /* Packe
+ int client_packet_errors = 0; /* Errors sending packets to clients. */
+ 
+ int add_agent_options = 0;/* If nonzero, add relay agent options. */
++int add_rfc3527_suboption = 0;/* If nonzero, add RFC3527 link 
selection sub-option. */
+ 
+ int agent_option_errors = 0;/* Number of packets forwarded without
+  agent options because there was no room. */
+@@ -104,6 +105,8 @@ struct server_list {
+   struct sockaddr_in to;
+ } *servers;
+ 
++struct interface_info *uplink;
++
+ #ifdef DHCPv6
+ struct stream_list {
+   struct stream_list *next;
+@@ -144,6 +147,7 @@ static const char url[] =
+  [-pf pid-file] [--no-pid]\n\
+  [-m append|replace|forward|discard]\n \
+  [-i interface0 [ ... -i interfaceN]\n \
++ [-l interface]\n \
+  server0 [ ... serverN]\n\n \
+dhcrelay -6   [-d] [-q] [-I] [-c hops] [-p port]\n \
+  [-pf pid-file] [--no-pid]\n\
+@@ -157,6 +161,7 @@ static const char url[] =
+ [-pf pid-file] [--no-pid]\n\
+ [-m append|replace|forward|discard]\n \
+ [-i interface0 [ ... -i interfaceN]\n \
++[-l interface]\n \
+ server0 [ ... serverN]\n\n
+ #endif
+ 
+@@ -314,6 +319,20 @@ main(int argc, char **argv) {
+   agent_relay_mode = discard;
+   } else
+   usage();
++  } else if (!strcmp (argv [i], -l)) {
++  add_agent_options = 1;
++  add_rfc3527_suboption = 1;
++  if (++i == argc)
++  usage();
++
++  status = interface_allocate(uplink, MDL);
++  if (status != ISC_R_SUCCESS)
++  log_fatal(%s: interface_allocate: %s,
++argv[i],
++isc_result_totext(status));
++  strcpy(uplink-name, argv[i]);
++  interface_snorf(uplink, INTERFACE_REQUESTED);
++  //interface_dereference(uplink, MDL);
+   } else if (!strcmp(argv[i], -D)) {
+ #ifdef DHCPv6
+   if (local_family_set  (local_family == AF_INET6)) {
+@@ -685,12 +704,17 @@ do_relay4(struct interface_info *ip, str
+  ip-addresses[0])))
+   return;
+ 
++  /* RFC3527: Replace giaddr address by uplink address. The original
++   * giaddr will be used in the link selection sub-option */
++  if (add_rfc3527_suboption)
++  packet-giaddr = uplink-addresses[0];
++

Re: [OpenWrt-Devel] [PATCH 01/10] cron: improve init script

2013-10-11 Thread Bruno Randolf

On 10/11/2013 01:35 AM, Yousong Zhou wrote:

Hi,

On 10 October 2013 19:02, Bruno Randolf b...@einfach.org wrote:

Add PATH in case it is missing (e.g. when executing the script from
ssh, like ssh IP /etc/init.d/cron restart).

Signed-off-by: Bruno Randolf b...@einfach.org
---
  package/busybox/files/cron | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/package/busybox/files/cron b/package/busybox/files/cron
index 465b1ab..79b0a46 100755
--- a/package/busybox/files/cron
+++ b/package/busybox/files/cron
@@ -5,6 +5,8 @@ START=50

  SERVICE_USE_PID=1

+PATH=/usr/sbin/:$PATH


Not sure here. Even `PATH` is needed, it should be `export PATH=xxx`
to make it visible to child processes.


It did fix problems with invocation via ssh at some point, this is very 
rare and it looks like it's not necessary for trunk any more, so feel 
free to ignore it.


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


Re: [OpenWrt-Devel] openwrt-devel Digest, Vol 94, Issue 35

2013-10-11 Thread Artur Wronowski
Some time ago I wrote a simple script to split bandwith per IP. Check
wiki (in Polish) http://openwrt.pl/doku.php/zastosowania:pasmo

2013/10/11  atilla.o.er...@gmail.com:
 dear friends
 is there any one use openwrt as bandwith slicer for per user?
 if yes please send me script to do it

 if is pay for i will pay it

 example senario:

 we have wan 100mbit/ps
 and 3 client pc

 client 1 mac =54:E6:FC:AD:4D:1D
 client 1 ip reserved for this mac is 192.168.1.76
 client 1 DL = 2 mbit/ps
 client 1 UL = 512 mb/ps

 client 2 mac =54:E6:FC:AD:4D:2D
 client 2 ip reserved for this mac is 192.168.1.77
 client 2 DL = 20 mbit/ps
 client 2 UL = 5 mb/ps

 client 3 mac =54:E6:FC:AD:4D:3D
 client 3 ip reserved for this mac is 192.168.1.78
 client 3 DL = 1 mbit/ps
 client 3 UL = 128 kb/ps






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



-- 
Pozdrawiam, Artur
Best regards, Artur
http://artekw.net / http://digi-led.pl / GG: 1518171 / Jabber: art...@jabbim.pl
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel