While attempting to bind ListenTCP to a certain interface, it was
discovered that it does not support subinterfaces (virtual interfaces)
while validating the contents of the "Local Network Interface" property. I
traced it back to the ListenerProperties class [1], which uses "
NetworkInterface.getNetworkInterfaces()" to pull a list of interfaces. This
method does not include subinterfaces, so further iteration using the
"getSubInterfaces()" method [2] on each interface would be required to
fully populate the list.

However, IP addresses are not found on the subinterfaces when using
"getInetAddresses()" on each interface. Instead, they can be found in the
enumeration returned by the parent interface. Further (needlessly complex)
logic would be required to determine which IP address is being requested
when specifying a virtual interface.

Additionally, in a scenario where someone has assigned a virtual interface
on a host and entered the parent interface into the "Local Network
Interface" property for ListenTCP, the code will find multiple IP addresses
for that parent interface... but only select the first one in the list. [3] I'm
uncertain as to how the IP addresses are ordered in the returned
enumeration, but I suspect that unpredictable outcomes would result based
upon that ordering.

Since this logic resides in the abstract class, multiple Listen processors
are affected.

I have opened NIFI-5445 [4] for this issue and submitted PR #2909 on GitHub
[5] which proposes a fix for this issue. Changing the property name to
"Local IP Address" will allow a simpler designation of intended operation
without complicating code. The IP address entry is validated against known
IP addresses on the system, as it was with the network interfaces. I tested
this change, and it binds as intended to IP addresses located on both
virtual and physical interfaces.

I'm not much of a developer, but I thought this was the best way to fix the
problem. However, I'm posting here for input on any other ways this could
be solved without changed property names... which I understand is not
trivial.

Also, please let me know if anything is wrong with the PR as this is my
first contribution.

Thank you.

-Nick


[1]
https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/listen/ListenerProperties.java#L41

[2]
https://docs.oracle.com/javase/8/docs/api/java/net/NetworkInterface.html#getSubInterfaces--

[3]
https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventProcessor.java#L189

[4] https://issues.apache.org/jira/browse/NIFI-5445

[5] https://github.com/apache/nifi/pull/2909

Reply via email to