Re: udhcpc: dont use BPF filter, users report problems (bugs 4598, 6746), commit e4785ca653d0e219926692c229673b2c1b8d6ac4

2014-02-19 Thread Denys Vlasenko
On Fri, Feb 14, 2014 at 6:15 PM, Vladislav Grishenko themi...@mail.ru wrote:
 At least for now, while we don't understand why filter breaks udhcpc for
 some users.

 There was bug in 2.6.19 bpf result handling, when unsigned 32-bit result how
 much of packet to retain was treated as signed integer. So, values could be
 interpreted as negative and packet drop verdict.

 Bug introduced with fda9ef5d679b07c9d9097aaf6ef7f069d794a8f9 [NET]: Fix
 sk-sk_filter field access in 2.6.19

 Buf fixed with dbcb5855d108b7fa20ab42567a5412ce9dcd776a [AF_PACKET]: Fix BPF
 handling in 2.6.20

 Perhaps it's the root of #4598 and #6746.

 Fix is trivial, return maximum signed value, not unsigned. It's sill fine to
 return some sane large integer to accept and leave the whole packet
 unchanged.

 /* L3: accept packet */

 -BPF_STMT(BPF_RET|BPF_K, 0x),

 +BPF_STMT(BPF_RET|BPF_K, 0x7fff),

Many thanks for an excellent analysis, committed the fix to git.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CTRL-ALT-DEL not working as expected. Seeking for advices

2014-02-19 Thread Denys Vlasenko
On Thu, Mar 21, 2013 at 12:18 AM, Bruno Cornec br...@victoria.frmug.org wrote:
 We have an opened bug report (Cf:
 http://trac.mondorescue.org/ticket/627) concerning the restoration
 phasebase don busybox, where a user is supposed to be able to press
 CTRL-ALT-DEL in order to reboot the computer before launching an
 automatic restore. This is not working as expected.

 We are up to now using version 1.18.5, with the attached .config file to
 compile busybox. We have an inittab file containing:

 #
 # inittab   This file describes how the INIT process should set up
 #   the system in the mindi-busybox context
 #

 # Order is important, read from bottom to top

 # By default launch the MondoRescue script
 console::sysinit:/etc/init.d/rcS

 console::restart:/sbin/init

 # Trap CTRL-ALT-DELETE
 null::ctrlaltdel:/sbin/reboot

 null::shutdown:/bin/killall klogd
 null::shutdown:/bin/killall syslogd
 null::shutdown:/bin/umount -a -r

 I'm testing mostly on KVM VMs, and simulate the CTRL-ALT-DEL with the
 sendkey command from the monitor window. This is working when we are at
 syslinux boot prompt, but as soon as we launch init, then we are unable
 to reboot the VM using CTRL-ALT-DEL. I also tested on real HW with the
 same result.

 So I'm surely doing something wrong, either in my inittab or in my
 congif of busybox, but I don't see what.

 I even tried with the latest 1.20.2 (which I may use as the base for the
 next stable version) without more luck either.

 Using showkey in the VM, I see that the sendkey command does indeed send
 the keys to the system, but it doesn't generate the reboot. I attached
 the corresponding capture.

 I read at
 http://lists.busybox.net/pipermail/busybox/2012-May/077855.html that a
 reason could be a non-busybox reboot but that's not our case. While we
 do replace some busybox commands by the native ones, reboot is linked to
 busybox (as well as halt, but not shutdown, which I just remarked
 now,but linking it to busybox doesn't change stuff anyway).

 So I'm looking for advises on how to debug more, or any hint wrt my
 usage.

Pressing CTRL-ALT-DEL sends SIGINT signal to process 1.
You want to make sure it reaches it.

The handler is installed here in init.c:

/* SIGINT (Ctrl-Alt-Del) must interrupt wait(),
 * setting handler without SA_RESTART flag.
 */
bb_signals_recursive_norestart((1  SIGINT), record_signo);

You can write a my_record_signo() function which also prints
signal number on stdout.

Then, you may want to similarly check whether this location
is reached in check_delayed_sigs():

if (sig == SIGINT)
run_actions(CTRLALTDEL);

-- 
vda
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CTRL-ALT-DEL not working as expected. Seeking for advices

2014-02-19 Thread Harald Becker
Hi !

On 19-02-2014 14:31 Denys Vlasenko vda.li...@googlemail.com
wrote:
 # Trap CTRL-ALT-DELETE
 null::ctrlaltdel:/sbin/reboot

Pressing CTRL-ALT-DEL sends SIGINT signal to process 1.
You want to make sure it reaches it.

Don't forget to set /proc/sys/kernel/ctrl-alt-del to 0 (zero)
to enable sending SIGINT to the init process.

e.g.: echo 0 /proc/sys/kernel/ctrl-alt-del

Without this most Linux kernel try an immediate reboot without
saving buffers etc., know to fail/hang on some emulators.

--
Harald
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: busybox udhcpc client

2014-02-19 Thread Denys Vlasenko
On Wed, Feb 19, 2014 at 2:30 AM, Mike Dean md...@emacinc.com wrote:
 Thank you for the prompt response on this.  I am looking into modifying the
 code for the busybox version of ifup to add the -s option and will see if I
 can make it work for my application.

-s option has a default. If you install your script in the default location,
you need no pass -s SCRIPT to udhcpc.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CTRL-ALT-DEL not working as expected. Seeking for advices

2014-02-19 Thread Denys Vlasenko
On Wed, Feb 19, 2014 at 2:48 PM, Harald Becker ra...@gmx.de wrote:
 On 19-02-2014 14:31 Denys Vlasenko vda.li...@googlemail.com
 wrote:
 # Trap CTRL-ALT-DELETE
 null::ctrlaltdel:/sbin/reboot

Pressing CTRL-ALT-DEL sends SIGINT signal to process 1.
You want to make sure it reaches it.

 Don't forget to set /proc/sys/kernel/ctrl-alt-del to 0 (zero)
 to enable sending SIGINT to the init process.

 e.g.: echo 0 /proc/sys/kernel/ctrl-alt-del

 Without this most Linux kernel try an immediate reboot without
 saving buffers etc., know to fail/hang on some emulators.

init.c does that already:

/* Turn off rebooting via CTL-ALT-DEL - we get a
 * SIGINT on CAD so we can shut things down gracefully... */
reboot(RB_DISABLE_CAD); /* misnomer */
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CTRL-ALT-DEL not working as expected. Seeking for advices

2014-02-19 Thread Harald Becker
Hi Denys !

On 19-02-2014 15:35 Denys Vlasenko vda.li...@googlemail.com
wrote:
On Wed, Feb 19, 2014 at 2:48 PM, Harald Becker ra...@gmx.de
wrote:
 On 19-02-2014 14:31 Denys Vlasenko vda.li...@googlemail.com
 wrote:
 # Trap CTRL-ALT-DELETE
 null::ctrlaltdel:/sbin/reboot

Pressing CTRL-ALT-DEL sends SIGINT signal to process 1.
You want to make sure it reaches it.

 Don't forget to set /proc/sys/kernel/ctrl-alt-del to 0 (zero)
 to enable sending SIGINT to the init process.

 e.g.: echo 0 /proc/sys/kernel/ctrl-alt-del

 Without this most Linux kernel try an immediate reboot without
 saving buffers etc., know to fail/hang on some emulators.

init.c does that already:

/* Turn off rebooting via CTL-ALT-DEL - we get a
 * SIGINT on CAD so we can shut things down
 gracefully... */ reboot(RB_DISABLE_CAD); /* misnomer */

Outch! ... if you do this before proc is mounted and system is
prepared successfully, most emulators fail and many linux systems
just hang when they receive a ctrl-alt-del. The command is right
(same as writing to /proc/sys/kernel/ctrl-alt-del) but time to do
this is wrong. Move that behind the initial system setup, then
enable ctrl-alt-del. As I had several trouble with Busybox init,
I dropped that and replaced it with my own programs, so I didn't
note earlier the wrong time you enable ctrl-alt-del in BB init.

I do not know what's the reason for this. I just found it
necessary to enable ctrl-alt-del at the right time in system
setup (and not earlier). Had several kinds of trouble on system
startup, when ctrl-alt-del is enabled to early and one presses
ctrl-alt-del. I did never look or try to analyze this.

--
Harald
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: mdev and post 3.6 kernels

2014-02-19 Thread Michael J. Hammel
On Sat, 2014-02-08 at 18:28 -0700, Michael J. Hammel wrote:
 I've been using 3.2.27 from the RPi repos with mdev and usbfs.  This
 worked fine to load drivers for wifi and webcams.  I'm trying to move to
 RPi's 3.10.y branch.  I've found that usbfs is deprecated and now I'm
 not sure how to find the usb devices and load the drivers.  mdev doesn't
 seem to report them.  I have it log every event at boot time and the usb
 devices don't show up.  
 
 Does anyone know if there are kernel config options that need to be
 enabled in 3.6+ (when usbfs was deprecated) for mdev to be notified of
 usb devices at boot time?  Or maybe suggestions on what mdev should be
 looking at to find them?  I could dig into mdev but I'm not sure where
 it should be looking for the devices.  lsusb shows them.  

Just to follow up my own post.

I tried nldev as a front end to mdev on the RPi 3.10.y kernel and this
seems to work much better than mdev by itself in finding usb devices.
nldev provides helper scripts and a replacement mdev.conf that needs to
be tweaked for things like mounting the mmc's 1st partition on boot (for
example) but otherwise found my usb connected network adapter (don't
remember if it found the webcam or not - forgot to check).

I've written a package for nldev for Buildroot 2013.11.  I'll try to
port to mainline soon and submit.

nldev: http://git.r-36.net/nldev/

-- 
Michael J. Hammel busy...@graphics-muse.org

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CTRL-ALT-DEL not working as expected. Seeking for advices

2014-02-19 Thread Denys Vlasenko
On Wed, Feb 19, 2014 at 3:58 PM, Harald Becker ra...@gmx.de wrote:
Pressing CTRL-ALT-DEL sends SIGINT signal to process 1.
You want to make sure it reaches it.

 Don't forget to set /proc/sys/kernel/ctrl-alt-del to 0 (zero)
 to enable sending SIGINT to the init process.

 e.g.: echo 0 /proc/sys/kernel/ctrl-alt-del

 Without this most Linux kernel try an immediate reboot without
 saving buffers etc., know to fail/hang on some emulators.

init.c does that already:

/* Turn off rebooting via CTL-ALT-DEL - we get a
 * SIGINT on CAD so we can shut things down
 gracefully... */ reboot(RB_DISABLE_CAD); /* misnomer */

 Outch! ... if you do this before proc is mounted and system is
 prepared successfully, most emulators fail and many linux systems
 just hang when they receive a ctrl-alt-del.

No. Calling sys_reboot with RB_DISABLE_CAD nee
LINUX_REBOOT_CMD_CAD_OFF nee zero
results in this code executing in kernel:

case LINUX_REBOOT_CMD_CAD_OFF:
C_A_D = 0;
break;

which in turn has this effect on Ctrl-Alt-Del keypress:

void ctrl_alt_del(void)
{
static DECLARE_WORK(cad_work, deferred_cad);

if (C_A_D)
schedule_work(cad_work);
else
kill_cad_pid(SIGINT, 1);
}

- exactly what init wants.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CTRL-ALT-DEL not working as expected. Seeking for advices

2014-02-19 Thread Harald Becker
Hi Denys !

No. Calling sys_reboot with RB_DISABLE_CAD nee
LINUX_REBOOT_CMD_CAD_OFF nee zero

- exactly what init wants.

Denys the problem is the time init does this call. When C-A-D is
enabled to early (before complete system initialization) many
systems fail badly and emulators tend to hang when you try C-A-D
in the phase of system startup. Per intention enabling C-A-D
shall only be done when system is up and init system is ready to
process action on SIGINT, not earlier. Current init seem to
enable C-A-D before executing sysinit actions. It shall be done
AFTER sysinit not BEFORE.

--
Harald
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: busybox udhcpc client

2014-02-19 Thread Mike Dean
Denys,

Okay great, thank you.  I'll look for that default.

Thanks,

Mike Dean

md...@emacinc.com
http://www.emacinc.com/

Engineer
EMAC, Inc.
618-529-4525 Ext. 330
618-457-0110 Fax
2390 EMAC Way
Carbondale, Il 62901



On Wed, Feb 19, 2014 at 8:34 AM, Denys Vlasenko vda.li...@googlemail.comwrote:

 On Wed, Feb 19, 2014 at 2:30 AM, Mike Dean md...@emacinc.com wrote:
  Thank you for the prompt response on this.  I am looking into modifying
 the
  code for the busybox version of ifup to add the -s option and will see
 if I
  can make it work for my application.

 -s option has a default. If you install your script in the default
 location,
 you need no pass -s SCRIPT to udhcpc.

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

RE: udhcpc: dont use BPF filter, users report problems (bugs 4598, 6746), commit e4785ca653d0e219926692c229673b2c1b8d6ac4

2014-02-19 Thread Vladislav Grishenko
Hi Denys,
Thanks, but filter code is still disabled

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -990,7 +990,6 @@ static int udhcp_raw_socket(int ifindex)
sock.sll_ifindex = ifindex;
xbind(fd, (struct sockaddr *) sock, sizeof(sock));
 
-#if 0 /* Several users reported breakage when BPF filter is used */
if (CLIENT_PORT == 68) {
/* Use only if standard port is in use */
/*
@@ -1041,7 +1040,6 @@ static int udhcp_raw_socket(int ifindex)
sizeof(filter_prog)) = 0)
log1(Attached filter to raw socket fd); // log?
}
-#endif
 
if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA,
const_int_1, sizeof(int))  0
--
1.7.2.5

Best Regards, Vladislav Grishenko


___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox