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 

[PATCH] Same-IP interfaces and runtime interface detection

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd Feature Request
View previous topic :: View next topic  
Author Message
Alexey Osipov



Joined: 02 May 2011
Posts: 5

PostPosted: Mon May 02, 2011 6:32 pm    Post subject: [PATCH] Same-IP interfaces and runtime interface detection Reply with quote

Hi, All!

First of all, thank you Thomas (and others?) for this great software!

I have made a couple of improvements to miniupnpd for meet my needs. It is a series of six patches, which adds next features:

1. Serve several LAN interfaces which all have same IP address.

Rationale: My Ubuntu-based server provides internet access for several users from my local network. Users connect to the server by means of PPtP and PPPoE tunnels. For every tunnel there is one PPP interface on the server. All user's PPP interfaces have the same IP address on the server. All users, surely, have different IP addresses. And everything works fine, except miniupnpd.

Old behavior: miniupnpd starts, opens one SSDP receive socket listening on ANY (0.0.0.0) address, add IP multicast membership for each LAN address specified in listening_ip config-file directives, opens SSDP notify and NAT-PMP sockets for each LAN address.

The problem: if there are several interfaces with same IP, miniupnpd adds multicast membership only to the first one, so the other interfaces just ignore SSDP traffic. Same with NAT-PMP 'public address change' notifications - it is sent only to the first interface from the group of same-ip interfaces.

New behavior: miniupnpd starts, opens one SSDP receive socket listening on ANY (0.0.0.0) address, gets the list of currently available network interfaces and add IP multicast membership for each interface from the list, which have an IP specified in listening_ip config-file directives, opens SSDP notify sockets for each LAN interface, opens NAT-PMP sockets for each LAN address. So all interfaces could accept SSDP traffic. When NAT-PMP 'public address change' notify emits, miniupnpd first set IP_MULTICAST_IF to correct interface, then send notification, and repeat for next interface.

2. Serve LAN interfaces, which was not exist during miniupnpd startup.
Rationale: The same as in 1. Users connects and disconnects during miniupnpd runs.

Old behavior: Shutdowned interfaces just disappeared from miniupnpd and produce some errors. New interfaces wasn't managed by miniupnpd.

New behavior: Shutdowned interfaces gracefully removed from miniupnpd. New interfaces (if their addresses specified in config file) become served by miniupnpd.

3. Hard limit on LAN interfaces count was removed, because you don't know how many interfaces there will be in runtime.

-------------

Because this dumb forum not allowing to upload files nor posting links unless you have one post, the link to the patches will be in the next post.

0001-Cosmetic-changes.patch
Some cosmetic changes like fixing line indents, removing extra tabs and spaces. Nothing serious.

0002-Remove-lan-addresses-limit-by-changing-storage-type-.patch
Change static array lan_addrs storage to dynamic linked list. The is the effective way to remove hard limit on LAN addresses count.

0003-Add-function-getifs-to-get-list-of-currently-availab.patch
Add a function getifs() which returns an array of currently available network interfaces.

0004-Separate-semantics-of-lan-address-and-lan-interface.patch
Implementation of feature 1. Create separate lan_iface_s structure for each network interface.

0005-Selection-of-multicast-interface-by-separate-functio.patch
Make sure that NAT-PMP 'public address change' notifications are sent from correct interface and for all clients.

0006-Runtime-network-interfaces-detection-Linux-only.patch
Runtime detection of new and removed network interfaces. Uses RTNETLINK socket. Seems to be Linux-only.

I will be glad, if this work will be accepted by upstream.

I'm also ready for discuss.

Alexey.

--------------

Some offtopic:
1. Is there only one author of this software? I mean the absence of AUTHORS file...
2. Do you use some public source version control system, where one can get the latest sources?
Back to top
View user's profile Send private message
Alexey Osipov



Joined: 02 May 2011
Posts: 5

PostPosted: Mon May 02, 2011 6:33 pm    Post subject: Reply with quote

Patches available here:

https://github.com/lion-simba/lion-simba.github.com

Applies cleanly to miniupnpd-1.5.20110309.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1431

PostPosted: Fri May 06, 2011 8:30 am    Post subject: Reply with quote

thank you for your work.
I'll have a look at it to put it uptream Wink
I'm currently working on IPv6 support.

about the authors, yep, there should be an AUTHORS file, but there is (should be?) an author line in the header of each source file, so you can add your name there !

I use my private CVS for quite a long time (6 years). It has been envisaged to switch to a private SVN or GIT, but still not done Wink
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Alexey Osipov



Joined: 02 May 2011
Posts: 5

PostPosted: Fri May 06, 2011 9:39 am    Post subject: Reply with quote

miniupnp wrote:
thank you for your work.
I'll have a look at it to put it uptream Wink

Cool Smile

miniupnp wrote:

about the authors, yep, there should be an AUTHORS file, but there is (should be?) an author line in the header of each source file, so you can add your name there !

Already done. I have put my name at the top of new files I created - ifacewatcher.c and ifacewatcher.h. But still, it could be nice to have an AUTHORS file. You can then reference AUTHORS file in your LICENSE file to mention the fact that the project have contributions from several people.

miniupnp wrote:

I use my private CVS for quite a long time (6 years). It has been envisaged to switch to a private SVN or GIT, but still not done Wink

I see. Try git. It's more suitable for decentralized development than svn. In any case, public SVC may attract new developers to the project. And, applying 3d-party patches will be more easy for you. Smile
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1431

PostPosted: Fri May 06, 2011 9:53 am    Post subject: Reply with quote

Alexey Osipov wrote:

miniupnp wrote:

I use my private CVS for quite a long time (6 years). It has been envisaged to switch to a private SVN or GIT, but still not done Wink

I see. Try git. It's more suitable for decentralized development than svn. In any case, public SVC may attract new developers to the project. And, applying 3d-party patches will be more easy for you. Smile

sorry should have written "... envisaged to switch to a public SVN or GIT ..." Wink
_________________
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: 1431

PostPosted: Wed Sep 28, 2011 6:54 am    Post subject: Reply with quote

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
Alexey Osipov



Joined: 02 May 2011
Posts: 5

PostPosted: Wed Sep 28, 2011 7:12 am    Post subject: Reply with quote

miniupnp wrote:
https://github.com/miniupnp/miniupnp !

Wow! Great news. Smile

But... there is only a client app. Will you publish source code of miniupnpd on github too?
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1431

PostPosted: Wed Sep 28, 2011 7:09 pm    Post subject: Reply with quote

Alexey Osipov wrote:
miniupnp wrote:
https://github.com/miniupnp/miniupnp !

Wow! Great news. Smile

But... there is only a client app. Will you publish source code of miniupnpd on github too?

yep sorry, I ran out of time yesterday ... I should be ok now
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Alexey Osipov



Joined: 02 May 2011
Posts: 5

PostPosted: Wed Sep 28, 2011 7:59 pm    Post subject: Reply with quote

miniupnp wrote:

yep sorry, I ran out of time yesterday ... I should be ok now


Okay, it's ok now. I will adapt my patches to current git master in near feature. I let you know, when I finish.
Back to top
View user's profile Send private message
caketreats



Joined: 28 Oct 2011
Posts: 2

PostPosted: Wed Nov 09, 2011 11:12 am    Post subject: Reply with quote

Thanks for all the information you provided above. I'm trying to set up a new work station for my team and our IT person has been working on it for 3 days straight already. I'll let him see all these notes and hopefully see progress. God bless! Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd Feature Request 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.