Skip to content

Conversation

@miteshkanjariya
Copy link
Contributor

@miteshkanjariya miteshkanjariya commented Apr 21, 2025

The OSPFv3 SNMP implementation was incorrectly returning internal state values directly without mapping them to the OSPFv3 MIB state values defined in RFC 5643. This caused a mismatch between the SNMP output and the actual interface states.

Added a mapping function to convert internal OSPFv3 interface states to their corresponding OSPFv3 MIB state values:

  • OSPF6_INTERFACE_DOWN (1) -> down(1)
  • OSPF6_INTERFACE_LOOPBACK (2) -> loopback(2)
  • OSPF6_INTERFACE_WAITING (3) -> waiting(3)
  • OSPF6_INTERFACE_POINTTOPOINT (4) -> pointToPoint(4)
  • OSPF6_INTERFACE_DR (7) -> designatedRouter(5)
  • OSPF6_INTERFACE_BDR (6) -> backupDesignatedRouter(6)
  • OSPF6_INTERFACE_DROTHER (5) -> otherDesignatedRouter(7)

This ensures that SNMP queries return the correct state values according to the OSPFv3 MIB specification.

Ticket: #4402285
Ticket: #4362862

UT:

before the fix:

root@uut# snmpwalk -v2c -c public localhost 1.3.6.1.2.1.191 | grep IfState

OSPFV3-MIB::ospfv3IfState.3.0 = INTEGER: otherDesignatedRouter(7)
OSPFV3-MIB::ospfv3IfState.4.0 = INTEGER: otherDesignatedRouter(7)
OSPFV3-MIB::ospfv3IfState.5.0 = INTEGER: standby(8)

root@uut:mgmt# vtysh -c "show ipv6 ospf interface swp1 json" 
{
  "swp1":{
    "status":"up",
    "type":"BROADCAST",
    "interfaceId":3,
    "internetAddress":[
      {
        "type":"inet6",
        "address":"2000:1000:1000:1000::2/80"
      },
      {
        "type":"inet6",
        "address":"fe80::202:ff:fe00:c/64"
      }
    ],
    "attachedToArea":true,
    "instanceId":0,
    "interfaceMtu":9216,
    "autoDetect":9216,
    "mtuMismatchDetection":"enabled",
    "areaId":"0.0.0.0",
    "cost":10,
    "ospf6InterfaceState":"BDR",
    "transmitDelaySec":1,
    "priority":1,
    "timerIntervalsConfigHello":10,
    "timerIntervalsConfigDead":40,
    "timerIntervalsConfigRetransmit":5,
    "timerPassiveIface":false,
    "dr":"0.0.0.5",
    "bdr":"0.0.0.8",
    "numberOfInterfaceScopedLsa":2,
    "pendingLsaLsUpdateCount":0,
    "pendingLsaLsUpdateTime":"00:00:00",
    "lsUpdateSendThread":"off",
    "pendingLsaLsUpdate":[
    ],
    "pendingLsaLsAckCount":0,
    "pendingLsaLsAckTime":"00:00:00",
    "lsAckSendThread":"off",
    "pendingLsaLsAck":[
    ],
    "grHelloDelaySecs":10,
    "authInfo":{
      "authType":"NULL"
    }
  }
}
root@uut# vtysh -c "show ipv6 ospf interface swp2 json" 
{
  "swp2":{
    "status":"up",
    "type":"BROADCAST",
    "interfaceId":4,
    "internetAddress":[
      {
        "type":"inet6",
        "address":"3000:1000:1000:1000::1/80"
      },
      {
        "type":"inet6",
        "address":"fe80::202:ff:fe00:d/64"
      }
    ],
    "attachedToArea":true,
    "instanceId":0,
    "interfaceMtu":9216,
    "autoDetect":9216,
    "mtuMismatchDetection":"enabled",
    "areaId":"0.0.0.1",
    "cost":10,
    "ospf6InterfaceState":"BDR",
    "transmitDelaySec":1,
    "priority":1,
    "timerIntervalsConfigHello":10,
    "timerIntervalsConfigDead":40,
    "timerIntervalsConfigRetransmit":5,
    "timerPassiveIface":false,
    "dr":"0.0.0.7",
    "bdr":"0.0.0.8",
    "numberOfInterfaceScopedLsa":2,
    "pendingLsaLsUpdateCount":0,
    "pendingLsaLsUpdateTime":"00:00:00",
    "lsUpdateSendThread":"off",
    "pendingLsaLsUpdate":[
    ],
    "pendingLsaLsAckCount":0,
    "pendingLsaLsAckTime":"00:00:00",
    "lsAckSendThread":"off",
    "pendingLsaLsAck":[
    ],
    "grHelloDelaySecs":10,
    "authInfo":{
      "authType":"NULL"
    }
  }
}
root@uut# vtysh -c "show ipv6 ospf interface swp3 json" 
{
  "swp3":{
    "status":"up",
    "type":"BROADCAST",
    "interfaceId":5,
    "internetAddress":[
      {
        "type":"inet6",
        "address":"3000:1000:1000:1000:1::1/80"
      },
      {
        "type":"inet6",
        "address":"fe80::202:ff:fe00:e/64"
      }
    ],
    "attachedToArea":true,
    "instanceId":0,
    "interfaceMtu":9216,
    "autoDetect":9216,
    "mtuMismatchDetection":"enabled",
    "areaId":"0.0.0.1",
    "cost":10,
    "ospf6InterfaceState":"DR",
    "transmitDelaySec":1,
    "priority":1,
    "timerIntervalsConfigHello":10,
    "timerIntervalsConfigDead":40,
    "timerIntervalsConfigRetransmit":5,
    "timerPassiveIface":false,
    "dr":"0.0.0.8",
    "bdr":"0.0.0.0",
    "numberOfInterfaceScopedLsa":1,
    "pendingLsaLsUpdateCount":0,
    "pendingLsaLsUpdateTime":"00:00:00",
    "lsUpdateSendThread":"off",
    "pendingLsaLsUpdate":[
    ],
    "pendingLsaLsAckCount":0,
    "pendingLsaLsAckTime":"00:00:00",
    "lsAckSendThread":"off",
    "pendingLsaLsAck":[
    ],
    "grHelloDelaySecs":10,
    "authInfo":{
      "authType":"NULL"
    }
  }
}
root@uut# 

After the fix:

root@uut# snmpwalk -v2c -c public localhost 1.3.6.1.2.1.191 | grep IfState

OSPFV3-MIB::ospfv3IfState.3.0 = INTEGER: backupDesignatedRouter(6)
OSPFV3-MIB::ospfv3IfState.4.0 = INTEGER: backupDesignatedRouter(6)
OSPFV3-MIB::ospfv3IfState.5.0 = INTEGER: designatedRouter(5)

root@uut# vtysh -c "show ipv6 ospf interface swp1 json" 
{
  "swp1":{
    "status":"up",
    "type":"BROADCAST",
    "interfaceId":3,
    "internetAddress":[
      {
        "type":"inet6",
        "address":"2000:1000:1000:1000::2/80"
      },
      {
        "type":"inet6",
        "address":"fe80::202:ff:fe00:c/64"
      }
    ],
    "attachedToArea":true,
    "instanceId":0,
    "interfaceMtu":9216,
    "autoDetect":9216,
    "mtuMismatchDetection":"enabled",
    "areaId":"0.0.0.0",
    "cost":10,
    "ospf6InterfaceState":"BDR",
    "transmitDelaySec":1,
    "priority":1,
    "timerIntervalsConfigHello":10,
    "timerIntervalsConfigDead":40,
    "timerIntervalsConfigRetransmit":5,
    "timerPassiveIface":false,
    "dr":"0.0.0.5",
    "bdr":"0.0.0.8",
    "numberOfInterfaceScopedLsa":2,
    "pendingLsaLsUpdateCount":0,
    "pendingLsaLsUpdateTime":"00:00:00",
    "lsUpdateSendThread":"off",
    "pendingLsaLsUpdate":[
    ],
    "pendingLsaLsAckCount":0,
    "pendingLsaLsAckTime":"00:00:00",
    "lsAckSendThread":"off",
    "pendingLsaLsAck":[
    ],
    "grHelloDelaySecs":10,
    "authInfo":{
      "authType":"NULL"
    }
  }
}
root@uut# vtysh -c "show ipv6 ospf interface swp2 json" 
{
  "swp2":{
    "status":"up",
    "type":"BROADCAST",
    "interfaceId":4,
    "internetAddress":[
      {
        "type":"inet6",
        "address":"3000:1000:1000:1000::1/80"
      },
      {
        "type":"inet6",
        "address":"fe80::202:ff:fe00:d/64"
      }
    ],
    "attachedToArea":true,
    "instanceId":0,
    "interfaceMtu":9216,
    "autoDetect":9216,
    "mtuMismatchDetection":"enabled",
    "areaId":"0.0.0.1",
    "cost":10,
    "ospf6InterfaceState":"BDR",
    "transmitDelaySec":1,
    "priority":1,
    "timerIntervalsConfigHello":10,
    "timerIntervalsConfigDead":40,
    "timerIntervalsConfigRetransmit":5,
    "timerPassiveIface":false,
    "dr":"0.0.0.7",
    "bdr":"0.0.0.8",
    "numberOfInterfaceScopedLsa":2,
    "pendingLsaLsUpdateCount":0,
    "pendingLsaLsUpdateTime":"00:00:00",
    "lsUpdateSendThread":"off",
    "pendingLsaLsUpdate":[
    ],
    "pendingLsaLsAckCount":0,
    "pendingLsaLsAckTime":"00:00:00",
    "lsAckSendThread":"off",
    "pendingLsaLsAck":[
    ],
    "grHelloDelaySecs":10,
    "authInfo":{
      "authType":"NULL"
    }
  }
}
root@uut# vtysh -c "show ipv6 ospf interface swp3 json" 
{
  "swp3":{
    "status":"up",
    "type":"BROADCAST",
    "interfaceId":5,
    "internetAddress":[
      {
        "type":"inet6",
        "address":"3000:1000:1000:1000:1::1/80"
      },
      {
        "type":"inet6",
        "address":"fe80::202:ff:fe00:e/64"
      }
    ],
    "attachedToArea":true,
    "instanceId":0,
    "interfaceMtu":9216,
    "autoDetect":9216,
    "mtuMismatchDetection":"enabled",
    "areaId":"0.0.0.1",
    "cost":10,
    "ospf6InterfaceState":"DR",
    "transmitDelaySec":1,
    "priority":1,
    "timerIntervalsConfigHello":10,
    "timerIntervalsConfigDead":40,
    "timerIntervalsConfigRetransmit":5,
    "timerPassiveIface":false,
    "dr":"0.0.0.8",
    "bdr":"0.0.0.0",
    "numberOfInterfaceScopedLsa":1,
    "pendingLsaLsUpdateCount":0,
    "pendingLsaLsUpdateTime":"00:00:00",
    "lsUpdateSendThread":"off",
    "pendingLsaLsUpdate":[
    ],
    "pendingLsaLsAckCount":0,
    "pendingLsaLsAckTime":"00:00:00",
    "lsAckSendThread":"off",
    "pendingLsaLsAck":[
    ],
    "grHelloDelaySecs":10,
    "authInfo":{
      "authType":"NULL"
    }
  }
}
root@uut#


Copy link
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

{
switch (state) {
case OSPF6_INTERFACE_DOWN:
return 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have actual defines returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to return it this way instead of returning actual # defines for the matching ones and magic number for the not-matching ones.

Alternatively, we could create new define for SNMP and return those
for example #OSPFV6_INTERFACE_DOWN_SNMP

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't want magic numbers. No-one is going to remember off the top of their head what 1 means, but they will pretty quickly understand OSPFV6_INTERFACE_DOWN_SNMP

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are we on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donaldsharp : I've replaced the hard-coded values with #defines. Could you please review again and approve it if everything looks good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riw777 @donaldsharp : Could you please take a look and approve if everything looks okay now ?

The OSPFv3 SNMP implementation was incorrectly returning internal state
values directly without mapping them to the OSPFv3 MIB state values
defined in RFC 5643. This caused a mismatch between the SNMP output
and the actual interface states.

Added a mapping function to convert internal OSPFv3 interface states
to their corresponding OSPFv3 MIB state values:
- OSPF6_INTERFACE_DOWN (1) -> down(1)
- OSPF6_INTERFACE_LOOPBACK (2) -> loopback(2)
- OSPF6_INTERFACE_WAITING (3) -> waiting(3)
- OSPF6_INTERFACE_POINTTOPOINT (4) -> pointToPoint(4)
- OSPF6_INTERFACE_DR (7) -> designatedRouter(5)
- OSPF6_INTERFACE_BDR (6) -> backupDesignatedRouter(6)
- OSPF6_INTERFACE_DROTHER (5) -> otherDesignatedRouter(7)

This ensures that SNMP queries return the correct state values
according to the OSPFv3 MIB specification.

Ticket: #4402285
Ticket: #4362862

Signed-off-by: Mitesh Kanjariya <[email protected]>
@miteshkanjariya
Copy link
Contributor Author

ci:rerun

1 similar comment
@miteshkanjariya
Copy link
Contributor Author

ci:rerun

@riw777 riw777 merged commit 01c740c into FRRouting:master Jul 8, 2025
14 checks passed
@miteshkanjariya miteshkanjariya deleted the ospfv6-mib-ifstate branch July 8, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants