Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicked IP address in search results goes to wrong vlan interface #778

Closed
listerr opened this issue Feb 11, 2022 · 2 comments
Closed

Clicked IP address in search results goes to wrong vlan interface #778

listerr opened this issue Feb 11, 2022 · 2 comments

Comments

@listerr
Copy link
Contributor

listerr commented Feb 11, 2022

ISSUE TYPE

Bug Report

VERSION
define( 'APPLICATION_VERSION', '6.2.0' );
define( 'APPLICATION_VERDATE', '2021111400' );
SUMMARY

When using the search feature, to search for IP addresses (e.g. /search?search=5.57.80.72),
the green labels for the IP addresses go to the wrong VLAN interface.

It seems to be using the id of the IP address in the ipv4address table instead
of the VLAN interface id, so:

Where the IP is 5.57.80.72, it goes to /interfaces/vlan/edit/72 (should be 88)
Clicking IP 5.57.82.72 goes to interfaces/vlan/edit/583 (should be 1083)

mysql> select * FROM ipv4address WHERE address = '5.57.80.72';
+----+--------+------------+------------+------------+
| id | vlanid | address    | created_at | updated_at |
+----+--------+------------+------------+------------+
| 72 |      1 | 5.57.80.72 | NULL       | NULL       |
+----+--------+------------+------------+------------+
1 row in set (0.00 sec)

mysql> select * FROM ipv4address WHERE address = '5.57.82.72';
+-----+--------+------------+------------+------------+
| id  | vlanid | address    | created_at | updated_at |
+-----+--------+------------+------------+------------+
| 583 |      1 | 5.57.82.72 | NULL       | NULL       |
+-----+--------+------------+------------+------------+
1 row in set (0.00 sec)

mysql> select id,ipv4addressid,ipv6addressid,virtualinterfaceid,vlanid from vlaninterface where ipv4addressid = '72';
+----+---------------+---------------+--------------------+--------+
| id | ipv4addressid | ipv6addressid | virtualinterfaceid | vlanid |
+----+---------------+---------------+--------------------+--------+
| 88 |            72 |            62 |                 90 |      1 |
+----+---------------+---------------+--------------------+--------+
1 row in set (0.01 sec)

mysql> select id,ipv4addressid,ipv6addressid,virtualinterfaceid,vlanid from vlaninterface where ipv4addressid = '583';
+------+---------------+---------------+--------------------+--------+
| id   | ipv4addressid | ipv6addressid | virtualinterfaceid | vlanid |
+------+---------------+---------------+--------------------+--------+
| 1083 |           583 |           452 |                680 |      1 |
+------+---------------+---------------+--------------------+--------+
1 row in set (0.00 sec)

Seems to be in

resources/views/search/additional/ip.foil.php

                    <?php if( $vli->ipv4address ): ?>
                        <li>
                            <a href="<?= route( 'vlan-interface@edit' , [ 'vli' => $vli->id ] ) ?>">
                                <span class="badge badge-<?php if( $vli->ipv6enabled ): ?>success<?php else: ?>danger<?php endif; ?>">
                                    <?= $t->ee( $vli->ipv4address->address ) ?>
                                </span>
                            </a>
                        </li>
                    <?php endif; ?>

                    <?php if( $vli->ipv6address ): ?>
                        <li>
                            <a href="<?= route( 'vlan-interface@edit' , [ 'vli' => $vli->id ] ) ?>">
                                <span class="badge badge-<?php if( $vli->ipv6enabled ): ?>success<?php else: ?>danger<?php endif; ?>">
                                    <?= $t->ee( $vli->ipv6address->address ) ?>
                                </span>
                            </a>
                        </li>
                    <?php endif; ?>

I've had a look through the code to see if it was something simple, couldn't figure out how to get the correct vlan interface id.

Also it's using $vli->ipv6enabled for both IPv4 and IPv6 links.

STEPS TO REPRODUCE
@nickhilliard
Copy link
Member

Also it's using $vli->ipv6enabled for both IPv4 and IPv6 links.

good catch - fixed in 54678d6.

@nickhilliard
Copy link
Member

ipv4address.id was implicitly stomping vlaninterface.id. This was already fixed for the ipv6 case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants