miniupnp.tuxfamily.org Forum Index miniupnp.tuxfamily.org
The forum about miniupnp and libnatpmp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AddPortMapping with WANPPPConnection and/or WANIPConnection

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Bugs
View previous topic :: View next topic  
Author Message
MacXperte



Joined: 31 Mar 2009
Posts: 3

PostPosted: Tue Mar 31, 2009 2:59 am    Post subject: AddPortMapping with WANPPPConnection and/or WANIPConnection Reply with quote

Using Transmission (1.5.1) on Mac OS X 10.4.11 with a Thomson TG585 v7 (8.2.1.5) I had the effect that both Transmission's log and the Router's log reported successful Addition of a Port Mapping, while it would still not show in the NAT-Mapping-List and the external port therefore remained unreachable.

Azureus at the same time could open working ports per UPnP, and in Transmission evrething worked if I would manually forward the Port.
So I compiled upnpc (changing '-shared' to '-dynamiclib' and '-soname' to '-install_name' - maybe you could add a switch for Mac OS X) and did some more testing.

I found out that instead of using the actually connected service 'WANPPPConnection', upnpc would default to adding the port to 'WANIPConnection' even after reporting that it was not connected. That of course explained all the strange symptoms. Following this trail into the source code I found this:
Code:
/* $Id: igd_desc_parse.c,v 1.8 2008/04/23 11:51:06 nanard Exp $ */
...
/* TODO : rewrite this code so it correctly handle descriptions with
 * both WANIPConnection and/or WANPPPConnection */

As this might well be the reason for many of the NAT-Problems reported in the miniupnp and Transmission Forums there should hopefully be a bugfix for this soon. One possible solution might be to test both services for their connection status (or external IP) and decide upon the result which one to use. But I know too little about different UPnP implementations to estimate wether these tests would always give useful results.

I had a look at what Azureus is doing and they have a more pragmatic approach: they just add the port twice - once for every found service. (Of course they also remove both of the mappings later.) This seems to me a good way to go and should also be not too difficult to implement.

Congratulations to this great project! I hope I could contribute a little.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1469

PostPosted: Thu Apr 02, 2009 9:30 pm    Post subject: Reply with quote

thank you for your suggestion.
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
MacXperte



Joined: 31 Mar 2009
Posts: 3

PostPosted: Mon Mar 15, 2010 3:26 pm    Post subject: Push! Reply with quote

miniupnp wrote:
thank you for your suggestion.

You are welcome!
But: still no fix?

I don't mean to be pushing, but it's been a year and Thomson Gateways are quite common in some parts of the world. Certainly this bug is producing more problems than the "Billion" bug, that recently received treatment.

I have all the respect for the time you voluntarily put into your project, so if there is anything else I can do to help resolving this issue, please ask me to.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1469

PostPosted: Mon Mar 15, 2010 3:35 pm    Post subject: Reply with quote

Too little time and too much work Sad
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1469

PostPosted: Wed Apr 07, 2010 10:06 am    Post subject: Reply with quote

could you test with miniupnpc-1.4.20100407.tar.gz ?
Tell me if it works with your router.
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
MacXperte



Joined: 31 Mar 2009
Posts: 3

PostPosted: Sat Apr 10, 2010 12:01 pm    Post subject: Test results Reply with quote

I did test and look into the version you provided, thanks a lot!
Short answer: it works - sometimes.

What you do now in state=1 of UPNP_GetValidIGD(), is to check another service if the first one listed in IGD.xml is not connected. If that secondary service is not connected either, you continue with the first one in state=2.

In situations where there are both WANIP and WANPPP services present but only one of them actually connects to the internet, this strategy works only in two cases:
1. the correct interface happens to be listed first in IGD.xml; or
2. the incorrect interface is not connected while the correct one is.

My router here for instance has a WANPPP that provides a triggered connection to the Internet and a WANIP that is connected to an internal address of my ISP for "Management".
It did work with that setup when both connections were up, but only because the old code would default to the last found service (which is the wrong one here) and the new code defaults to the first one found (lucky strike!). When the "real" Internet-connection was idle (waiting for a trigger) and the "Management" connection was (always-)on, it went the wrong way again.

The points I am trying to make are:
1. Relying on the order of services in IGD.xml is uncertain.
2. Relying on the "Connected" status can be deceiving.

More generally speaking, I don't think it is wise to let the code make any assumptions about wether or not to use one of the found services.
The order of listing in IGD.xml is not meaningful in any way.
Connection up is no guarantee that it leads to the Internet, while connection down might be only temporarily (like with a triggered connection).
Likewise, testing for the external IP seems to be a good idea only on first look: having a valid IP doesn't mean connectivity, having no IP can be temporary, having a local unroutable address doesn't mean the user might not want to make a redirection through that connection anyway.
So the only reliable fact that remains is the sheer existence of the service(s), with each of them potentially being useful.

I would like to express my own constructive thoughts on the matter, if I may.
- As you already presume a maximum of two usable services, you might as well - instead of naming them 'first' and 'second' - call them 'wanip' and 'wanppp' and let IGDendelt() fill them accordingly. This also makes it easy to treat each of the services differently, should the need to do so ever arise. Alternatively you could make it more generic by filling an array with all the found services.
- Ports should be opened on every found service, no further conditions necessary. If both wanip and wanppp exist, use both. If you created an array of found services, loop through and use each of them.
- When listing redirections, parse all found services.
- After use, close all ports that have been opened.

You can still check for the connection status and report it, but other than that, state=1 and state=2 might probably as well be merged. If on the other hand you think some of the implementations need that finer control to redirect only through connected services, you could make the behaviour configurable. As most implementations will use MiniUPnP primarily for real-world usage and not for diagnostic purposes, I still think the default behaviour should try to make it "just work" in as many situations as possible.

What do you think?
Again, if I can help in any way, I'm available.
Greetings, Florian
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1469

PostPosted: Mon Apr 12, 2010 3:57 pm    Post subject: Reply with quote

the best way to have it working exactly the way you want is to implement it and then send me a patch.
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1469

PostPosted: Sun Oct 09, 2011 6:51 am    Post subject: Reply with quote

the project on github can help you :
https://github.com/miniupnp/miniupnp
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
© 2007 Thomas Bernard, author of MiniUPNP.