Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 60

Thread: [uPnP] Problem with uPnP, adding forward: router stops forwarding

  1. #31
    Quote Originally Posted by barsju
    Sigh. I was kinda hoping you had NGT.. You being Norwegian and all.. OH well. But what I am really more interested in is if I need to make any changes in my wl500g? What should the WAN settings be? Still automatic ip? As there probably isn't anyone with my exact problem, maybe someone can make a qualified guess?

    Sjur
    If you set your modem in bridge mode, your router must handle some new stuff/parameters like connection type and so on...

    1. Shut down your modem...

    2. I suggest you to set wl500g in gateway mode and launch a quick setup first... Take also a look at dhcp section and enable it.

    3. Reboot your router...

    4. And finaly start your modem!

    This should work

  2. #32
    @ barsju...

    Some more infos about my own experience using msn messenger:

    Regardless firewall and upnp settings, everithing works fine except audio features! The only way I can get it work is when I connect to some one who use the same MSN version as me... 7 beta.

  3. #33
    Still having tourble with this. Has anyone got msn videochat running through wl500g?

    Now I have swithced on IP-Passthrough feature on the wl500g, and that works fine. But I still cannot get msn videochat to work through the wl500g. I can how ever make it work when I bypass the wl500g and connect my pc directly to the modem.

    I have watched what happens with iptraf and I can see:
    - UDP packets to 255.255.255.255 on port 1900 (MSN UPnP discovery)
    - UDP packets to and from local ip and peers-ip on typical upnp port.
    - UDP packets to and from external ip to peers ip on typical upnp port.

    So that should indicate that the outgoing packets actually go through the router but gets blocked by the modem, as my peer does not receive any packets form me. But then again, when I try without the router it works, indicating that the problem lies within the router...

    Anyone have any ideas on how to find out where the problem really is? Or any other ideas on how to fix this? I read a review of wl500gx that said that it had bad/non functioning UPnP support and that they couldn't get MSN to work through it, and that the ports that were opened did not get closed. Is this true, and has it been fixed in custom firmware?

    S

    PS: I have of course tried other video chat software, but I don't have a standard webcam but a camcorder with a webcam function. Problem is that the webcam/usb driver is real crap and it only works with msn.

  4. #34

    How to remove UPnP entries from iptables?

    Because of a feature/bug UPnP ports never gets closed on the wl500g. When they are opened the entries are stored in nvram so they will even survive a reboot. So if you have opened and used UPnP at one point there might be open ports in your firewall. An easy way to remove them is to reset to factory default. If that is not an option you can clear them from nvram.

    Here is how you do that:

    First check for unwanted forwarding rules in iptables:
    Code:
    iptables -L FORWARD
    If there are open ports that you can't account for they are likely caused by UPnP. Now check nvram for those entries:
    Code:
    nvram show | grep "forward_port"
    If you find entries there you can remove them one by one like this:
    Code:
    nvram unset forward_portX
    where X is for the rule number (ex. forward_port0)

    I have also written this script to help to remove a number of rules:
    Code:
    #!/bin/sh 
    tlr=$1  
    while [ $tlr -le $2 ]  
    do 
     	nvram unset forward_port$tlr
      	tlr=`expr $tlr + 1`  
    done
    It takes to and from rule number as parameters. You can run f.eks like this:
    Code:
    ./clearUPnP 0 10
    which will clear rules from 0 to 10.

    If someone would like to write a script that will clear all forward_port rules on boot, that would be a nice extension. Unless of course Asus or Oleg change this behaviour in comming FW releases.

    S.
    Edit: Don't forget to
    Code:
    nvarm commit
    before you reboot!
    Last edited by barsju; 18-03-2005 at 08:41.

  5. #35
    I guess this script would also do the trick:
    Code:
    #!/bin/sh
    for line in `nvram show | grep "port_forward" | sed "s/ //"`
    do
    	i=`expr index $line "="`
    	let i=i-1
    	rule=`expr substr $line 1 $i`
    	nvram unset $rule
    done
    It should remove all rules that starts with "port_forward", and can for instance be started from post-boot, to remove all UPnP ports upon reboot of router.

    Haven't really tested it properly as I have already removed the entries from nvram, so use at own risk! I can suggest replacing the last line in the loop with:
    Code:
    echo "nvram unset $rule"
    to make sure you don't get any unexpected behaviour, before you run it for real.

    S.

  6. #36

    How do you stop upnp from dying?

    There's no forum for bugs so once again I'm just making this problem known here (in case people don't already know). I didn't find it specifically when searching but maybe I'm just no good at searching... Now that I'm into compiling and such I'm going to compile upnp in debug mode and try to isolate the issue.

    For me, upnp will die after x amount of time. That's all I know for now. Azureus lets me know, and I set up crond to restart it when it's gone and log in such a case, and it's true that it is dying. I'll try to figure it out and post results here.

  7. #37
    Happy to read this... before, I've though that my windows settings were bad.

    I've noticed this issue by the way that "asus gateway device icon" disappear from the list of upnp devices in winxp!

    But I've also noticed that the icon shows up again after a while, and so on...
    so I guess wl500g auto-restart the process when killed.

    This seems to happend with all fw versions that I've tried since 1.6.x.x

  8. #38
    I've set up crond to run a preservation script every minute in order to make sure important processes are running. "watchdog" is supposed to do this but I'm not sure it always does... Maybe it just takes longer. Anyway, here's what my preservation script put out:
    05/03/05 12:06:01PM upnp: restarting
    05/03/05 12:19:02PM upnp: restarting
    05/03/05 12:23:02PM upnp: restarting
    05/03/05 12:30:01PM upnp: restarting
    05/03/05 12:37:01PM upnp: restarting
    05/03/05 12:47:01PM upnp: restarting
    05/03/05 1:00:02PM upnp: restarting
    05/03/05 1:07:02PM upnp: restarting
    05/03/05 1:14:01PM upnp: restarting
    05/03/05 1:21:01PM upnp: restarting
    05/03/05 1:28:01PM upnp: restarting
    ...
    05/03/05 3:13:01PM upnp: restarting
    05/03/05 3:20:01PM upnp: restarting

    A lot of that, of course, looks like it's happening every 7 minutes. It may be crashing due to the request of some application for me, though it should never crash like that anyway. It's annoying. I'm actually using the latest version of upnp too now (the one from 1.9.4.0 beta). So no solution there.

  9. #39
    Well, I ran upnp with strace...
    Here's how it ends:
    Code:
    ...
    sendto(4, "NOTIFY * HTTP/1.1 \r\nHOST: 239.25"..., 329, 0, {sa_family=AF_INET, sin_port=htons(1900), sin_addr=inet_addr("239.255.255.250")}, 16) = 329
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    --- SIGUSR1 (Stack fault) @ 0 (0) ---
    write(1, "upnp reinitialize.\n", 19upnp reinitialize.
    )    = 19
    close(4)                                = 0
    close(3)                                = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
    ioctl(3, 0x8915, 0x7fff79e8)            = 0
    close(3)                                = 0
    socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
    setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
    bind(3, {sa_family=AF_INET, sin_port=htons(5431), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
    listen(3, 10)                           = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
    ioctl(4, 0x8913, 0x7fff7980)            = 0
    setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
    bind(4, {sa_family=AF_INET, sin_port=htons(1900), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
    ioctl(4, 0x8933, {6, "br0"})            = 0
    setsockopt(4, SOL_IP, IP_ADD_MEMBERSHIP, "\357\377\377\372\0\0\0\0\6\0\0\0", 12) = 0
    setsockopt(4, SOL_IP, IP_MULTICAST_IF, [16885952], 4) = 0
    setsockopt(4, SOL_IP, IP_MULTICAST_TTL, "\4", 1) = 0
    rt_sigaction(SIGUSR1, {0x10000000, [], SA_SIGINFO|0x403104}, {0x10000000, [], SA_SIGINFO|0x403104}, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 940000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 940000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 940000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 940000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 940000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 930000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    close(4)                                = 0
    close(3)                                = 0
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 910000}}) = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 90000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 70000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    exit(0)                                 = ?
    Related source code:
    upnp/igd/igd.c:
    Code:
    void sigusr1_handler(int i)
    {
        extern void reinit_lan_interface(struct iface *pif);
        extern struct iface *global_lans;
        struct iface *pif;
    
        printf("upnp reinitialize.\n");
        bump_generation();
    
        for (pif = global_lans; pif; pif = pif->next) 
    	reinit_lan_interface(pif);
    
        /* re-install a signal handler for SIGUSR1 */
        signal(SIGUSR1, sigusr1_handler);
    }
    Hmm. I'm not sure if this could be considered ironic, but it appears that perhaps watchdog itself is doing the killing of upnp. After all, it did die when my IP address was being renewed recently, despite the 7-minute deaths from before...

    MORE:
    rc/network.c:
    Code:
    void
    wan_up(char *wan_ifname)
    {
    ...
    	stop_upnp();
    	start_upnp();		
    ...
    }
    rc/watchdog.c:
    Code:
    int ntp_timesync(void)
    {
    ...
    		   	if (tm.tm_year>100) // More than 2000
    		   	{
    		      		sync_interval = (atoi(nvram_safe_get("ntp_interval_x")) ? : 2) * 360;
    			  	logmessage("ntp client", "Synchronizing time with %s...", nvram_safe_get("ntp_servers"));
    
    				stop_upnp();
    				start_upnp();
    		   	}
    ...
    }
    Apparently from what it says there (and through other stuff I've omitted), if the time has been synchronized once before and it's time to sync the time again, upnp will be stopped and started. So this means upnp stops and starts every 2 hours? Uh, ooh, ouch. Is that really necessary?

    Also, I tried (with it running with strace) killing it using killall -USR1 upnp through another terminal...

    Code:
    ...
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f0)            = 0
    close(6)                                = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff7990)            = 0
    close(6)                                = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f8)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 40000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 40000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    That's what happened up to the next "SIGALRM" -- no exit.
    Last edited by tomilius; 05-05-2005 at 09:16.

  10. #40
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    Who is sending SIGALRM to it?

  11. #41
    Well, itself, isn't it? I know very little about this stuff, but I'm guessing SIGALRM has something to do with timers... and it uses timers... (see upnp.c)

    All this occurred over and over:
    Code:
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f0)            = 0
    close(6)                                = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff7990)            = 0
    close(6)                                = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f8)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f0)            = 0
    close(6)                                = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff7990)            = 0
    close(6)                                = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f8)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 60000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 60000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8946, 0x7fff7998)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 110000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 110000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    time(NULL)                              = 1115260616
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 20000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 20000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    time(NULL)                              = 1115260616
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 810000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 810000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f0)            = 0
    close(6)                                = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff7990)            = 0
    close(6)                                = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f8)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 60000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={1, 60000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8946, 0x7fff7998)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 940000}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 930000}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    --- SIGALRM (Alarm clock) @ 0 (0) ---
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f0)            = 0
    close(6)                                = 0
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff7990)            = 0
    close(6)                                = 0
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "J\0\0\0", 11)                  = 4
    read(5, "\32\0\0\0", 13)                = 4
    read(5, "\303\0\0\0", 12)               = 4
    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6
    ioctl(6, 0x8915, 0x7fff78f8)            = 0
    close(6)                                = 0
    setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}, NULL) = 0
    getitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={2, 0}}) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    sigreturn()                             = ? (mask now [RT_37 RT_38 RT_39 RT_41 RT_45 RT_50 RT_61])
    rt_sigprocmask(SIG_BLOCK, [ALRM], NULL, 16) = 0
    rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 16) = 0
    _newselect(5, [3 4], NULL, NULL, NULL)  = ? ERESTARTNOHAND (To be restarted)
    Last edited by tomilius; 05-05-2005 at 09:24.

  12. #42
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    check SIGALRM handler then, to check why it's bailing out.

  13. #43
    Well, it bails out if it receives an interrupt...

    Code:
    void interrupt_handler(int i)
    {
        //    signal(SIGINT, SIG_DFL);
        send_advertisements(SSDP_BYEBYE);
        global_exit_now = TRUE;
    }
    ... Most of the time, I think, it goes away because the DHCP lease has expired and is being renewed or the time is updating (code confirms, afaik, that it restarts under these circumstances). This might be a cheap and simple way to avoid having to rebuild firewall rules, but I probably don't know what I'm talking about here. I mean, maybe that's what it does to rebuild them.

  14. #44
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    it appears, that this code handles SIGINT only...

  15. #45
    Uh, well, like I said, I know very little about this (I pretty much figured out that this "SIG" stuff existed a few weeks ago and haven't done anything involving it again until today). Here's everything related to SIGALRM in all of upnp:

    Code:
    static void block_alarm()
    {
        sigset_t set;
    
        sigemptyset(&set);
        sigaddset(&set, SIGALRM);
        sigprocmask(SIG_BLOCK, &set, NULL);
    }
    
    static void unblock_alarm()
    {
        sigset_t set;
    
        sigemptyset(&set);
        sigaddset(&set, SIGALRM);
        sigprocmask(SIG_UNBLOCK, &set, NULL);
    }
    Isn't SIGALRM a timer? That's just what I'd guess.

    In int upnp_main:
    Code:
        memset(&timer, 0, sizeof(timer));
        timer.it_interval.tv_sec = 30;
        timer.it_value.tv_sec = 30;
        td1 = enqueue_event(&timer, (event_callback_t)connection_reaper, NULL);
    
        memset(&timer, 0, sizeof(timer));
        timer.it_interval.tv_sec = 30;
        timer.it_value.tv_sec = 30;
        td2 = enqueue_event(&timer, (event_callback_t)gena_subscription_reaper, NULL);
    
        memset(&timer, 0, sizeof(timer));
        timer.it_interval.tv_sec = UPNP_REFRESH;
        timer.it_value.tv_sec = UPNP_REFRESH;
        td3 = enqueue_event(&timer, (event_callback_t)periodic_advertiser, (void *) SSDP_ALIVE);
    The functions:
    in upnp.c
    Code:
    static void connection_reaper(timer_t t, void *arg)
    {
        struct net_connection **pnet, *net;
        time_t now;
        int i = 0;
    
        now = time(NULL);
        pnet = &net_connections;
        while (*pnet) {
    	i++;
    	if ((*pnet)->expires && (*pnet)->expires < now) {
    	    net = *pnet;
    	    *pnet = (*pnet)->next;
    	    assert(net->func);
    	    (*(net->func))(CONNECTION_DELETE, net, net->arg);
    	    continue;
    	}
    	pnet = &((*pnet)->next);
        }
    }
    in gena.c:
    Code:
     
    void gena_subscription_reaper(timer_t t, void *arg)
    {
        PDevice pdev;
        PService psvc;
        time_t now;
    
        now = time(NULL);
    
        forall_devices(pdev) {
    	forall_services(pdev, psvc) {
    	    reap_service_subscriptions(psvc, now);
    	}
        }
    }
    
    
    static void reap_service_subscriptions(PService psvc, time_t now)
    {
        PSubscription *ppsr, sr;
        int i = 0;
    
        ppsr = &(psvc->subscriptions);
        while (*ppsr) {
    	i++;
    	if ((*ppsr)->expires && (*ppsr)->expires < now) {
    	    UPNP_SUBSCRIBE(("Reaping subscription for %s.\n", psvc->template->name));
    	    sr = *ppsr;
    	    *ppsr = (*ppsr)->next;
    		
    	    free(sr->cb_host);
    	    free(sr->cb_path);
    	    free(sr);
    	    continue;
    	}
    	ppsr = &((*ppsr)->next);
        }
    }
    in ssdp.c
    Code:
    /* Should really call this twice to give the UDP packets a better chance of reaching their destination. 
    */
    static void advertise_device(PDevice pdev, ssdp_t sstype, struct iface *pif, struct sockaddr *addr, int addrlen)
    {
        UFILE *upkt;
        PService psvc;
        char tmpbuf[100], svctype[100];
        const char *loc = location(pdev, pif);
    
        // create a growable string UFILE.
        if ((upkt = usopen(NULL, 0))) {
    
    	if (ISROOT(pdev)) {
    	    snprintf(tmpbuf, sizeof(tmpbuf), "%s::upnp:rootdevice", pdev->udn);
    	    ssdp_packet(
    		upkt, sstype, "upnp:rootdevice", tmpbuf,
    		loc, SSDP_REFRESH);
    	    if (sendto(pif->ssdp_connection->fd, ubuffer(upkt), utell(upkt), 0, addr, addrlen) < 0)
    		UPNP_ERROR(("sendto failed at %s:%d - err %d\n", __FILE__, __LINE__, errno));
    	    uflush(upkt); 	// reset the packet buffer before we build another.
    	}
    
    	// advertise device by UDN
    	ssdp_packet( upkt, sstype, pdev->udn, pdev->udn, 
    		     loc, SSDP_REFRESH);
    	if (sendto(pif->ssdp_connection->fd, ubuffer(upkt), utell(upkt), 0, addr, addrlen) < 0)
    	    UPNP_ERROR(("sendto failed at %s:%d - err %d\n", __FILE__, __LINE__, errno));
    	uflush(upkt); 	// reset the packet buffer before we build another.
        
    	// advertise device by combination of UDN and type
    	snprintf(tmpbuf, sizeof(tmpbuf), "%s::%s", pdev->udn, pdev->template->type);
    	ssdp_packet( upkt, sstype, pdev->template->type, tmpbuf,
    		     loc, SSDP_REFRESH);
    	if (sendto(pif->ssdp_connection->fd, ubuffer(upkt), utell(upkt), 0, addr, addrlen) < 0)
    	    UPNP_ERROR(("sendto failed at %s:%d - err %d\n", __FILE__, __LINE__, errno));
    	uflush(upkt); 	// reset the packet buffer before we build another.
    
    	// advertise the services...
    	for (psvc = pdev->services; psvc; psvc = psvc->next) {
    	    snprintf(svctype, sizeof(svctype), "urn:%s:service:%s", psvc->template->schema, psvc->template->name);
    	    snprintf(tmpbuf, sizeof(tmpbuf), "%s::%s", pdev->udn, svctype);
    
    	    ssdp_packet( upkt, sstype, svctype, tmpbuf,
    			 loc, SSDP_REFRESH);
    
    	    if (sendto(pif->ssdp_connection->fd, ubuffer(upkt), utell(upkt), 0, addr, addrlen) == -1) 
    		UPNP_ERROR(("sendto failed at %s:%d - err %d\n", __FILE__, __LINE__, errno));
    	    uflush(upkt); 	// reset the packet buffer before we build another.
    	}
    
    	// release the growable string UFILE.
    	uclose(upkt);
        }
    
    }
    
    void periodic_advertiser(timer_t t, ssdp_t sstype)
    {
        send_advertisements(sstype);
    }
    
    /* Construct the multicast address and send out the appropriate device advertisement packets. */
    void send_advertisements(ssdp_t sstype)
    {
        struct sockaddr_in addr;
        struct iface *pif;
        PDevice pdev;
    
        addr.sin_family = AF_INET;
        addr.sin_addr.s_addr = inet_addr(SSDP_IP);
        addr.sin_port = htons(SSDP_PORT);
    
        for (pif = global_lans; pif; pif = pif->next) {
    	forall_devices(pdev) {
    	    advertise_device(pdev, sstype, pif, (struct sockaddr *)&addr,  sizeof(addr));
    	}
        }
    }
    That's about everything I can find even slightly related, and all I'm looking for is some kind of "dropping out." I don't completely understand the strace result differences from it dropping out after SIGUSR1 and it not dropping out, but I think it's all related to the internal stop/start commands in network.c of rc and the other places... (resets on time update, resets on wan change).

    See, I don't exactly understand why under these circumstances I'd ever see anything in my logs (about upnp not being found running and having to be started by my crond script) or why it would ever not be running since it's reset, not stopped... at least, that's the way it's supposed to be... but, eh.
    Last edited by tomilius; 05-05-2005 at 10:11.

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. upnp server wl500 g
    By jaapieo in forum Dutch Discussion - Nederlands
    Replies: 22
    Last Post: 14-02-2006, 12:49
  2. help upnp media server
    By mikaell in forum WL-HDD Q&A
    Replies: 5
    Last Post: 27-02-2005, 02:13

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •