[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Possible bug in "ip -6 route show" command
From:       JRoyal () atto ! com
Date:       2020-03-16 13:09:55
Message-ID: OFDE652C38.2FF35344-ON85258529.005D9497-8525852D.004851D4 () LocalDomain
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I believe that there is a bug in the print_route function in iproute.c.

If one creates a custom IPv6 routing table (for source-based routing, in
our case), the table is not visible using the "ip -6 route show table
<tablename>" command. Nothing is returned if this command is run. This is
not the case for custom IPv4 tables; "ip route show table <tablename>"
works fine, showing whatever has been added to the custom table. This
difference in behavior appears to be due to the following lines in
print_route in iproute.c:

	if (r->rtm_family == AF_INET6) {
		if (G_filter.tb) {
			if (G_filter.tb < 0) {
				if (!(r->rtm_flags & RTM_F_CLONED)) {
					return 0;
				}
			} else {
				if (r->rtm_flags & RTM_F_CLONED) {
					return 0;
				}
				if (G_filter.tb == RT_TABLE_LOCAL) {
					if (r->rtm_type != RTN_LOCAL) {
						return 0;
					}
				} else if (G_filter.tb == RT_TABLE_MAIN) {
					if (r->rtm_type == RTN_LOCAL) {
						return 0;
					}
				} else {
					return 0;
<--------------------------------------------
				}
			}
		}

This code appears to prevent any custom IPv6 table from being viewed,
though the table creation (also using the "ip -6 route" command) works fine
as far as I can tell.

In order to view custom IPv6 tables, I replaced the above code with:

	if (r->rtm_family == AF_INET6) {
		if (G_filter.tb) {
			if (G_filter.tb < 0) {
				if (!(r->rtm_flags & RTM_F_CLONED)) {
					return 0;
				}
			} else {
				if (r->rtm_flags & RTM_F_CLONED) {
					return 0;
				}
				if (G_filter.tb == RT_TABLE_LOCAL) {
					if (r->rtm_type != RTN_LOCAL) {
						return 0;
					}
				} else if (G_filter.tb == RT_TABLE_MAIN) {
					if (r->rtm_type == RTN_LOCAL) {
						return 0;
					}
				} else if (G_filter.tb != r->
rtm_table){      <----------------
					return 0;
				}
			}
		}

This change makes the AF_INET6 code closer to the logic used by the AF_INET
code and results in the "ip -6 route show table <tablename>" command
correctly showing the custom table.

To test this:
ip -6 route add default via EEEE::01 dev eth2 table 5

ip -6 route show table 5

If the fix works, you'll see a 1-line custom routing table.

"Route -A inet6" does not show the custom table, but since the "route"
command doesn't support custom tables, that is expected.

We are using Busybox 1.22.1 on an old Angstrom version, but the
above-mentioned code is present in recent downloadable source (2020-03-03
00:20 is the last I checked), and I don't see any mention of the above in
the bug tracker, so I suspect that this issue is still present,
particularly given the simplicity of the workaround and the unlikelyhood of
a fix being applied elsewhere.
--
--
Jeremy Royal
Senior Software Engineer I
ATTO Technology, Inc.
Phone:  +1.716.691.1999 ext. 507
Fax: +1.716.691.9353
www.atto.com

Dear Loyal Partners:
Each year we look forward to meeting with our customers and partners at
Avid Connect, Dell Technologies World and NAB in Las Vegas but we also
strongly support the decisions to cancel these shows this year as a
protective measure against the spread of COVID-19. We will be providing
more information regarding our plans to engage our community through
alternative mediums including virtual online events along with our industry
partners who had plans to attend this year.





This electronic transmission and any attachments hereto are intended only for the use \
of the individual or entity to which it is addressed and may contain confidential \
information belonging to ATTO Technology, Inc. If you have reason to believe that you \
are not the intended recipient, you are hereby notified that any disclosure, copying, \
distribution or the taking of any action in reliance on the contents of this \
electronic transmission is strictly prohibited. If you have reason to believe that \
you have received this transmission in error, please notify ATTO immediately by \
return e-mail and delete and destroy this communication.


[Attachment #5 (unknown)]

<html><body><p><font size="2" face="sans-serif">I believe that there is a bug in the \
print_route function in iproute.c.</font><br><br><font size="2" face="sans-serif">If \
one creates a custom IPv6 routing table (for source-based routing, in our case), the \
table is not visible using the &quot;ip -6 route show table &lt;tablename&gt;&quot; \
command. Nothing is returned if this command is run. This is not the case for custom \
IPv4 tables; &quot;ip route show table &lt;tablename&gt;&quot; works fine, showing \
whatever has been added to the custom table. This difference in behavior appears to \
be due to the following lines in print_route in iproute.c:</font><br><br><font \
size="2" face="sans-serif">        if (r-&gt;rtm_family == AF_INET6) \
{</font><br><font size="2" face="sans-serif">                if (G_filter.tb) \
{</font><br><font size="2" face="sans-serif">                        if (G_filter.tb \
&lt; 0) {</font><br><font size="2" face="sans-serif">                                \
if (!(r-&gt;rtm_flags &amp; RTM_F_CLONED)) {</font><br><font size="2" \
face="sans-serif">                                        return 0;</font><br><font \
size="2" face="sans-serif">                                }</font><br><font size="2" \
face="sans-serif">                        } else {</font><br><font size="2" \
face="sans-serif">                                if (r-&gt;rtm_flags &amp; \
RTM_F_CLONED) {</font><br><font size="2" face="sans-serif">                           \
return 0;</font><br><font size="2" face="sans-serif">                                \
}</font><br><font size="2" face="sans-serif">                                if \
(G_filter.tb == RT_TABLE_LOCAL) {</font><br><font size="2" face="sans-serif">         \
if (r-&gt;rtm_type != RTN_LOCAL) {</font><br><font size="2" face="sans-serif">        \
return 0;</font><br><font size="2" face="sans-serif">                                 \
}</font><br><font size="2" face="sans-serif">                                } else \
if (G_filter.tb == RT_TABLE_MAIN) {</font><br><font size="2" face="sans-serif">       \
if (r-&gt;rtm_type == RTN_LOCAL) {</font><br><font size="2" face="sans-serif">        \
return 0;</font><br><font size="2" face="sans-serif">                                 \
}</font><br><font size="2" face="sans-serif">                                } else \
{</font><br><font size="2" face="sans-serif">                                        \
return 0; &nbsp;&lt;--------------------------------------------</font><br><font \
size="2" face="sans-serif">                                }</font><br><font size="2" \
face="sans-serif">                        }</font><br><font size="2" \
face="sans-serif">                }</font><br><br><font size="2" \
face="sans-serif">This code appears to prevent any custom IPv6 table from being \
viewed, though the table creation (also using the &quot;ip -6 route&quot; command) \
works fine as far as I can tell. </font><br><br><font size="2" face="sans-serif">In \
order to view custom IPv6 tables, I replaced the above code with:</font><br><br><font \
size="2" face="sans-serif">        if (r-&gt;rtm_family == AF_INET6) \
{</font><br><font size="2" face="sans-serif">                if (G_filter.tb) \
{</font><br><font size="2" face="sans-serif">                        if (G_filter.tb \
&lt; 0) {</font><br><font size="2" face="sans-serif">                                \
if (!(r-&gt;rtm_flags &amp; RTM_F_CLONED)) {</font><br><font size="2" \
face="sans-serif">                                        return 0;</font><br><font \
size="2" face="sans-serif">                                }</font><br><font size="2" \
face="sans-serif">                        } else {</font><br><font size="2" \
face="sans-serif">                                if (r-&gt;rtm_flags &amp; \
RTM_F_CLONED) {</font><br><font size="2" face="sans-serif">                           \
return 0;</font><br><font size="2" face="sans-serif">                                \
}</font><br><font size="2" face="sans-serif">                                if \
(G_filter.tb == RT_TABLE_LOCAL) {</font><br><font size="2" face="sans-serif">         \
if (r-&gt;rtm_type != RTN_LOCAL) {</font><br><font size="2" face="sans-serif">        \
return 0;</font><br><font size="2" face="sans-serif">                                 \
}</font><br><font size="2" face="sans-serif">                                } else \
if (G_filter.tb == RT_TABLE_MAIN) {</font><br><font size="2" face="sans-serif">       \
if (r-&gt;rtm_type == RTN_LOCAL) {</font><br><font size="2" face="sans-serif">        \
return 0;</font><br><font size="2" face="sans-serif">                                 \
}</font><br><font size="2" face="sans-serif">                                } else \
if (G_filter.tb != r-&gt;rtm_table){ &nbsp; &nbsp; \
&nbsp;&lt;----------------</font><br><font size="2" face="sans-serif">                \
return 0;</font><br><font size="2" face="sans-serif">                                \
}</font><br><font size="2" face="sans-serif">                        \
}</font><br><font size="2" face="sans-serif">                }</font><br><font \
size="2" face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font><br><font size="2" \
face="sans-serif">This change makes the AF_INET6 code closer to the logic used by the \
AF_INET code and results in the &quot;ip -6 route show table &lt;tablename&gt;&quot; \
command correctly showing the custom table. </font><br><br><font size="2" \
face="sans-serif">To test this:</font><br><font size="2" face="sans-serif">ip -6 \
route add default via EEEE::01 dev eth2 table 5</font><br><br><font size="2" \
face="sans-serif">ip -6 route show table 5</font><br><br><font size="2" \
face="sans-serif">If the fix works, you'll see a 1-line custom routing table. \
</font><br><br><font size="2" face="sans-serif">&quot;Route -A inet6&quot; does not \
show the custom table, but since the &quot;route&quot; command doesn't support custom \
tables, that is expected.</font><br><br><font size="2" face="sans-serif">We are using \
Busybox 1.22.1 on an old Angstrom version, but the above-mentioned code is present in \
recent downloadable source (2020-03-03 00:20 is the last I checked), and I don't see \
any mention of the above in the bug tracker, so I suspect that this issue is still \
present, particularly given the simplicity of the workaround and the unlikelyhood of \
a fix being applied elsewhere. </font><br><font size="2" \
face="sans-serif">--</font><br><font size="2" face="sans-serif">--</font><br><font \
size="2" face="sans-serif">Jeremy Royal</font><br><font size="2" \
face="sans-serif">Senior Software Engineer I</font><br><font size="2" \
face="sans-serif">ATTO Technology, Inc.</font><br><font size="2" \
face="sans-serif">Phone: &nbsp;+1.716.691.1999 ext. 507</font><br><font size="2" \
face="sans-serif">Fax: +1.716.691.9353</font><br><a href="www.atto.com"><font \
size="2" face="sans-serif">www.atto.com</font></a><br><br><font size="1" \
color="#603181" face="sans-serif"><b>Dear Loyal Partners:</b></font><br><font \
size="1" color="#603181" face="sans-serif">Each year we look forward to meeting with \
our customers and partners at Avid Connect, Dell Technologies World and NAB in Las \
Vegas but we also strongly support the decisions to cancel these shows this year as a \
protective measure against the spread of COVID-19. We will be providing more \
information regarding our plans to engage our community through alternative mediums \
including virtual online events along with our industry partners who had plans to \
attend this year.</font><p><p><font face="sans-serif"><br /><br /><font size="1">This \
electronic transmission and any attachments hereto are intended only for the use of \
the individual or entity to which it is addressed and may contain confidential \
information belonging to ATTO Technology, Inc. If you have reason to believe that you \
are not the intended recipient, you are hereby notified that any disclosure, copying, \
distribution or the taking of any action in reliance on the contents of this \
electronic transmission is strictly prohibited. If you have reason to believe that \
you have received this transmission in error, please notify ATTO immediately by \
return e-mail and delete and destroy this communication.</font></font> </body></html>



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic