Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loopback adapter with SetCurrentSubnet
27-10-2016, 07:59 PM
Post: #1
Loopback adapter with SetCurrentSubnet
At present, it isn't possible to use the loopback network adapter if SetCurrentSubnet has been called. The currently supported combinations are:

1) loopback only (SetUseLoopbackNetworkAdapter)
2) all subnets excluding loopback (default setting)
3) all subnets including loopback (SetIncludeLoopbackNetworkAdapter)
4) single subnet excluding loopback (SetCurrentSubnet)

The missing combination is:
5) single subnet including loopback (SetCurrentSubnet and SetIncludeLoopBackNetworkAdapter)
This doesn't work because SetCurrentSubnet effectively overrides SetIncludeLoopbackNetworkAdapter, making this combination equivalent to 4).

MinimServer requires combination 5) and I noticed recently that this combination doesn't work as I had been expecting. I am attaching a patch that adds support for this combination.

The patch updates the code in DviProtocolUpnp::DviProtocolUpnp, DviProtocolUpnp::HandleInterfaceChange, DviServer::Initialise and DviServer::SubnetListChanged so that these methods no longer have separate code paths when single subnet mode is enabled. Instead, the logic in these methods follows a single path that takes into account the settings for single subnet and loopback.

I have tested this patch and it appears to work as intended in all cases.


Attached File(s)
.zip  loopback.zip (Size: 2.32 KB / Downloads: 2)
Find all posts by this user
27-10-2016, 08:12 PM
Post: #2
RE: Loopback adapter with SetCurrentSubnet
(27-10-2016 07:59 PM)simoncn Wrote:  ...I am attaching a patch that adds support for this combination.

Thanks. The changes look good. I'll get them integrated tomorrow.
Find all posts by this user
28-10-2016, 02:36 PM
Post: #3
RE: Loopback adapter with SetCurrentSubnet
Having looked at the changes more closely, I've changed my mind about them. Sorry.

I think this effectively changes the single subnet mode to run on up to 2 subnets, with one being hard-coded to loopback? This wouldn't be safe or desirable for some users of ohNet.

Would it be possible for you to get support for loopback by running on all subnets instead? If not, we might need yet another initialisation option along the lines of the existing SetUseLoopbackNetworkAdapter() and SetIncludeLoopbackNetworkAdapter() ones.
Find all posts by this user
28-10-2016, 06:54 PM
Post: #4
RE: Loopback adapter with SetCurrentSubnet
(28-10-2016 02:36 PM)simonc Wrote:  Having looked at the changes more closely, I've changed my mind about them. Sorry.

I think this effectively changes the single subnet mode to run on up to 2 subnets, with one being hard-coded to loopback? This wouldn't be safe or desirable for some users of ohNet.

This would only happen if the user has called both SetCurrentSubnet() and SetIncludeLoopBackNetworkAdapter().

If the user wants to run on a single subnet (not loopback), he/she can call SetCurrentSubnet() and not call either SetIncludeLoopBackNetworkAdapter() or SetUseLoopBackNetworkAdapter().

If the user wants to run on a single subnet (loopback), he/she can call SetUseLoopBackNetworkAdapter().

This means that all existing single-subnet cases are still available with my proposed change.

Quote:Would it be possible for you to get support for loopback by running on all subnets instead?

No, because there are cases where it is necessary for MinimServer to support a single non-loopback subnet and the loopback adapter.

Quote:If not, we might need yet another initialisation option along the lines of the existing SetUseLoopbackNetworkAdapter() and SetIncludeLoopbackNetworkAdapter() ones.

This would work for me. It could be something like SetAlwaysIncludeLoopbackNetworkAdapter(). However, I am not sure that this extra API is necessary, given what I have said above about all combinations being available without the need for an extra API.
Find all posts by this user
09-11-2016, 03:57 PM
Post: #5
RE: Loopback adapter with SetCurrentSubnet
(28-10-2016 06:54 PM)simoncn Wrote:  
(28-10-2016 02:36 PM)simonc Wrote:  Having looked at the changes more closely, I've changed my mind about them. Sorry.

I think this effectively changes the single subnet mode to run on up to 2 subnets, with one being hard-coded to loopback? This wouldn't be safe or desirable for some users of ohNet.

This would only happen if the user has called both SetCurrentSubnet() and SetIncludeLoopBackNetworkAdapter().

If the user wants to run on a single subnet (not loopback), he/she can call SetCurrentSubnet() and not call either SetIncludeLoopBackNetworkAdapter() or SetUseLoopBackNetworkAdapter().

If the user wants to run on a single subnet (loopback), he/she can call SetUseLoopBackNetworkAdapter().

This means that all existing single-subnet cases are still available with my proposed change.

Thanks for the explanation. I think I understand why the change is safe now. The only remaining issue is that I can't use the current diff...

The diff can be applied using patch but fails to compile. I'm not convinced it applied correctly; I tried applying it manually but struggled with the lack of context in the diff (normally influenced by -u option I think) .

Can you re-create the diff against the latest ohNet code please? A pull request on github would be easy to handle too if that'd be less hassle.
Find all posts by this user
09-11-2016, 08:39 PM
Post: #6
RE: Loopback adapter with SetCurrentSubnet
(09-11-2016 03:57 PM)simonc Wrote:  Thanks for the explanation. I think I understand why the change is safe now. The only remaining issue is that I can't use the current diff...

The diff can be applied using patch but fails to compile. I'm not convinced it applied correctly; I tried applying it manually but struggled with the lack of context in the diff (normally influenced by -u option I think) .

Can you re-create the diff against the latest ohNet code please? A pull request on github would be easy to handle too if that'd be less hassle.

I'm sorry about the patch format. I had accidentally omitted the -u option when I created it. I have recreated it from the current ohNet source with the -u option and I have applied it to the current source using patch -p0 and confirmed that it compiles OK.

I am also including the patched source files so that you can check against these to confirm that the patch has applied correctly.

Many thanks!


Attached File(s)
.zip  loopback2.zip (Size: 14.41 KB / Downloads: 2)
Find all posts by this user
11-11-2016, 10:31 AM
Post: #7
RE: Loopback adapter with SetCurrentSubnet
(09-11-2016 08:39 PM)simoncn Wrote:  I'm sorry about the patch format. I had accidentally omitted the -u option when I created it. I have recreated it from the current ohNet source with the -u option and I have applied it to the current source using patch -p0 and confirmed that it compiles OK.

I am also including the patched source files so that you can check against these to confirm that the patch has applied correctly.

Many thanks!

Thanks. I've applied the patch now so it should be on github later today.

Note that I made one tiny change to the patch. The MakeIpAddress macro is now in Network.h rather than Defines.h
Find all posts by this user
11-11-2016, 10:37 AM
Post: #8
RE: Loopback adapter with SetCurrentSubnet
(11-11-2016 10:31 AM)simonc Wrote:  Thanks. I've applied the patch now so it should be on github later today.

Thanks very much!

Quote:Note that I made one tiny change to the patch. The MakeIpAddress macro is now in Network.h rather than Defines.h

That makes sense. I wasn't sure where was the best place to put it.
Find all posts by this user


Forum Jump: