On Thu, Jan 30, 2025 at 02:34:48PM +0100, Eelco Chaudron wrote:
>
>
> On 17 Jan 2025, at 15:25, Adrian Moreno wrote:
>
> > Drop events are generated from the kernel, not ovs-vswitchd so instead
> > of relying on nla decoding, copy the skb's device name directly into the
> > event.
> >
> > Signed-off-by: Adrian Moreno <[email protected]>
>
> This patch is giving me odd errors:
>
> 1897177.728659707 33 handler206 1058347 ens2f0np0
> (system@ovs-system) 0 1496 132 0
> 1897177.728660453 3 handler172 1058313 ens2f0np0
> (system@ovs-system) 0 1496 132 0
> 1897177.728666183 33 handler206 1058347 ens2f0np0
> (system@ovs-system) 0 1496 132 0
> Exception ignored on calling ctypes callback function: <function
> RingBuf.open_ring_buffer.<locals>.ringbuf_cb_ at 0x7f6e5dc59670>
> Traceback (most recent call last):
> File "/usr/lib/python3.9/site-packages/bcc/table.py", line 1266, in
> ringbuf_cb_
> ret = callback(ctx, data, size)
> File
> "/root/Documents/reviews/OVS_main_DPDK_v24.11.1/ovs_github/utilities/usdt-scripts/./upcall_monitor.py",
> line 328, in print_event
> port = event.dev_name.decode("utf-8")
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position 0:
> invalid continuation byte
> Exception ignored on calling ctypes callback function: <function
> RingBuf.open_ring_buffer.<locals>.ringbuf_cb_ at 0x7f6e5dc59670>
> Traceback (most recent call last):
> File "/usr/lib/python3.9/site-packages/bcc/table.py", line 1266, in
> ringbuf_cb_
> ret = callback(ctx, data, size)
>
> I guess the buffer is wrapping, and the entries are not zeroed out, causing
> problems in the USDT case. Adding the below solved it for me:
>
> diff --git a/utilities/usdt-scripts/upcall_monitor.py
> b/utilities/usdt-scripts/upcall_monitor.py
> index 104225cad..3ba17952b 100755
> --- a/utilities/usdt-scripts/upcall_monitor.py
> +++ b/utilities/usdt-scripts/upcall_monitor.py
> @@ -179,6 +179,7 @@ int do_trace(struct pt_regs *ctx) {
> event->cpu = bpf_get_smp_processor_id();
> event->pid = bpf_get_current_pid_tgid();
> event->result = 0;
> + event->dev_name[0] = 0;
> bpf_get_current_comm(&event->comm, sizeof(event->comm));
>
> Other than the above, no other comments.
>
Good catch! Thanks!
> > ---
> > utilities/usdt-scripts/upcall_monitor.py | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/utilities/usdt-scripts/upcall_monitor.py
> > b/utilities/usdt-scripts/upcall_monitor.py
> > index 8943fd205..104225cad 100755
> > --- a/utilities/usdt-scripts/upcall_monitor.py
> > +++ b/utilities/usdt-scripts/upcall_monitor.py
> > @@ -133,6 +133,7 @@ import sys
> > # Actual eBPF source code
> > #
> > ebpf_source = """
> > +#include <linux/netdevice.h>
> > #include <linux/skbuff.h>
> >
> > #define MAX_PACKET <MAX_PACKET_VAL>
> > @@ -148,6 +149,7 @@ struct event_t {
> > u64 key_size;
> > char comm[TASK_COMM_LEN];
> > char dpif_name[32];
> > + char dev_name[16];
> > unsigned char pkt[MAX_PACKET];
> > unsigned char key[MAX_KEY];
> > };
> > @@ -237,6 +239,7 @@ int kretprobe__ovs_dp_upcall(struct pt_regs *ctx)
> > u64 pid = bpf_get_current_pid_tgid();
> > struct inflight_upcall *upcall;
> > int ret = PT_REGS_RC(ctx);
> > + struct net_device *dev;
> > u64 size;
> >
> > upcall = inflight_upcalls.lookup(&pid);
> > @@ -265,6 +268,9 @@ int kretprobe__ovs_dp_upcall(struct pt_regs *ctx)
> > event->pkt_size = upcall->skb->len;
> > event->upcall_type = upcall->upcall_type;
> > event->key_size = 0;
> > + bpf_probe_read(&dev, sizeof(upcall->skb->dev),
> > + ((char *)upcall->skb + offsetof(struct sk_buff, dev)));
> > + bpf_probe_read_kernel(&event->dev_name, 16, dev->name);
> >
> > size = upcall->skb->len - upcall->skb->data_len;
> > if (size > MAX_PACKET) {
> > @@ -318,7 +324,9 @@ def print_event(ctx, data, size):
> > nla, key_dump = decode_nlm(
> > bytes(event.key)[: min(event.key_size, options.flow_key_size)]
> > )
> > - if "OVS_KEY_ATTR_IN_PORT" in nla:
> > + if event.dev_name:
> > + port = event.dev_name.decode("utf-8")
> > + elif "OVS_KEY_ATTR_IN_PORT" in nla:
> > port_no = struct.unpack("=I", nla["OVS_KEY_ATTR_IN_PORT"])[0]
> > port = dp_map.get_port_name(dp.partition("@")[-1], port_no)
> > else:
> > --
> > 2.48.1
> >
> > _______________________________________________
> > dev mailing list
> > [email protected]
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev