Skip to content

Commit

Permalink
zebra: Add LTTng traces for kernel to zebra notification
Browse files Browse the repository at this point in the history
Add LTTNG traces for ipv4/ipv6 address add/del events from kernel to zebra

Ticket: #3147896
MR-661
Testing:
```
root@r1:mgmt:/var/log/lttng-traces# /usr/lib/frr/frr_babeltrace.py frr-local-zebra-onboot | grep addr_add_del
2024-02-20T21:56:16.732 frr_zebra:if_ip_addr_add_del {'ifname': 'swp1', 'address': '1000::1', 'location': 'RTM_NEWADDR IPv6'}
2024-02-20T21:56:38.329 frr_zebra:if_ip_addr_add_del {'ifname': 'eth0', 'address': '192.168.0.15', 'location': 'RTM_DELADDR IPv4'}
2024-02-20T21:56:39.526 frr_zebra:if_ip_addr_add_del {'ifname': 'eth0', 'address': '192.168.0.15', 'location': 'RTM_NEWADDR IPv4'}
2024-02-20T21:56:39.584 frr_zebra:if_ip_addr_add_del {'ifname': 'swp1', 'address': '1000::1', 'location': 'RTM_DELADDR IPv6'}```

Signed-off-by: Vijayalaxmi Basavaraj <vbasavaraj@nvidia.com>
  • Loading branch information
vijayalaxmi-basavaraj authored and chiragshah6 committed Jan 29, 2025
1 parent 35ec5ee commit d753680
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tools/frr_babeltrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ def location_if_dplane_ifp_handling_new(field_val):
return ("RTM_NEWLINK UPD")


def location_if_ip_addr_add_del(field_val):
if field_val == 0:
return "RTM_NEWADDR IPv4"
elif field_val == 1:
return "RTM_DELADDR IPv4"
elif field_val == 2:
return "RTM_NEWADDR IPv6"
elif field_val == 3:
return "RTM_DELADDR IPv6"


def print_location_gr_deferral_timer_start(field_val):
if field_val == 1:
return ("Tier 1 deferral timer start")
Expand Down Expand Up @@ -768,6 +779,12 @@ def parse_frr_zebra_if_dplane_ifp_handling_new(event):
parse_event(event, field_parsers)


def parse_frr_zebra_if_ip_addr_add_del(event):
field_parsers = {"location": location_if_ip_addr_add_del,
"address": print_prefix_addr}
parse_event(event, field_parsers)


def parse_frr_bgp_gr_deferral_timer_start(event):
field_parsers = {"location": print_location_gr_deferral_timer_start,
"afi": print_afi_string,
Expand Down Expand Up @@ -969,6 +986,24 @@ def main():
parse_frr_zebra_if_dplane_ifp_handling,
"frr_zebra:if_dplane_ifp_handling_new":
parse_frr_zebra_if_dplane_ifp_handling_new,
"frr_zebra:if_ip_addr_add_del":
parse_frr_zebra_if_ip_addr_add_del,
"frr_bgp:gr_deferral_timer_start":
parse_frr_bgp_gr_deferral_timer_start,
"frr_bgp:gr_deferral_timer_expiry":
parse_frr_bgp_gr_deferral_timer_expiry,
"frr_bgp:gr_eors":
parse_frr_bgp_gr_eors,
"frr_bgp:gr_eor_peer":
parse_frr_bgp_gr_eor_peer,
"frr_bgp:gr_start_deferred_path_selection":
parse_frr_bgp_gr_start_deferred_path_selection,
"frr_bgp:gr_send_fbit_capability":
parse_frr_bgp_gr_send_fbit_capability,
"frr_bgp:gr_continue_deferred_path_selection":
parse_frr_bgp_gr_continue_deferred_path_selection,
"frr_bgp:gr_zebra_update":
parse_frr_bgp_gr_zebra_update,
"frr_bgp:router_id_update_zrecv":
parse_frr_bgp_router_id_update_zrecv,
"frr_bgp:interface_address_oper_zrecv":
Expand Down
8 changes: 8 additions & 0 deletions zebra/connected.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_trace.h"

/* communicate the withdrawal of a connected address */
static void connected_withdraw(struct connected *ifc)
Expand Down Expand Up @@ -379,6 +380,7 @@ void connected_add_ipv4(struct interface *ifp, int flags,
* the notification. So it should be safe to set the REAL flag here. */
SET_FLAG(ifc->conf, ZEBRA_IFC_REAL);

frrtrace(3, frr_zebra, if_ip_addr_add_del, ifp->name, ifc->address, 0);
connected_update(ifp, ifc);
}

Expand Down Expand Up @@ -556,6 +558,9 @@ void connected_delete_ipv4(struct interface *ifp, int flags,
} else
ifc = connected_check_ptp(ifp, &p, NULL);

if (ifc)
frrtrace(3, frr_zebra, if_ip_addr_add_del, ifp->name, ifc->address, 1);

connected_delete_helper(ifc, &p);
}

Expand Down Expand Up @@ -622,6 +627,7 @@ void connected_add_ipv6(struct interface *ifp, int flags,
* might still be running.
*/
SET_FLAG(ifc->conf, ZEBRA_IFC_REAL);
frrtrace(3, frr_zebra, if_ip_addr_add_del, ifp->name, ifc->address, 2);
connected_update(ifp, ifc);
}

Expand Down Expand Up @@ -650,6 +656,8 @@ void connected_delete_ipv6(struct interface *ifp,
} else
ifc = connected_check_ptp(ifp, &p, NULL);

if (ifc)
frrtrace(3, frr_zebra, if_ip_addr_add_del, ifp->name, ifc->address, 3);
connected_delete_helper(ifc, &p);
}

Expand Down
15 changes: 15 additions & 0 deletions zebra/zebra_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,21 @@ TRACEPOINT_EVENT(

TRACEPOINT_LOGLEVEL(frr_zebra, netlink_ipneigh_change, TRACE_INFO)

TRACEPOINT_EVENT(
frr_zebra,
if_ip_addr_add_del,
TP_ARGS(char *, name,
struct prefix *, address,
uint8_t, loc),
TP_FIELDS(
ctf_string(ifname, name)
ctf_array(unsigned char, address, address, sizeof(struct prefix))
ctf_integer(uint8_t, location, loc)
)
)

TRACEPOINT_LOGLEVEL(frr_zebra, if_ip_addr_add_del, TRACE_INFO)

TRACEPOINT_EVENT(
frr_zebra,
netlink_parse_info,
Expand Down

0 comments on commit d753680

Please sign in to comment.