Skip to content

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

@listerr

Description

@listerr
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions