LPM match - error in control plane

Hello,
Below I have a table in a p4 program and i want to add some rules from a controller for this table.
My problem is when i make a write request through p4runtime service and i get a grpc error with a status unknown.
The problem i think it is in the lpm field.
if i call the write_IPv4_Rules like this:
write_IPv4_Rules(p4info_helper,ingress_sw,ip_dest,32,dst_mac,1)
it seems to work fine.
But when i call it using 24 instead of 32 in the lpm(which is my goal) write_IPv4_Rules(p4info_helper,ingress_sw,ip_dest,24,dst_mac,1),
i get the grpc error which i said above.


def write_IPv4_Rules(p4info_helper,ingress_sw,ipv4_dst,lpm,dst_mac,out_port):
    table_entry = p4info_helper.buildTableEntry(
        table_name="MyIngress.ipv4_lpm",
        match_fields={
            "hdr.ipv4.dstAddr": (ipv4_dst, lpm)
        },
        action_name="MyIngress.ipv4_forward",
        action_params={
            "dstAddr": dst_mac,
            "port": out_port
        })
    ingress_sw.WriteTableEntry(table_entry)
    print("Installed ipv4 rule on %s" % ingress_sw.name)
table ipv4_lpm {
        key = {
            hdr.ipv4.dstAddr: lpm;
        }
        actions = {
            ipv4_forward;
            send_to_cpu;
        }
        size = 1024;
        default_action = send_to_cpu();
    }

Can someone help me with it?

You probably didn’t mask the trailing bits properly in your value.

See P4Runtime Specification. For an LPM match:

“Don’t care” bits must be 0 in value.

Note that you can parse the gRPC error to get a more useful error message: P4Runtime Specification