# LPM match - error in control plane

**URL:** <https://forum.p4.org/t/lpm-match-error-in-control-plane/253>\
**Category:** Getting Started with P4\
**Created:** [March 1, 2022, 1:12pm UTC](https://forum.p4.org/t/lpm-match-error-in-control-plane/253 "2022-03-01T13:12:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppavlidis](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@ppavlidis](https://forum.p4.org/u/ppavlidis)\
**Post date:** [March 1, 2022, 1:12pm UTC](https://forum.p4.org/t/lpm-match-error-in-control-plane/253/1 "2022-03-01T13:12:27Z")

</div>

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.

```auto

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)

```

```auto
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?

---

<div class="post-metadata">

**Author:** ![antonin](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@antonin](https://forum.p4.org/u/antonin)\
**Post date:** [March 2, 2022, 12:42am UTC](https://forum.p4.org/t/lpm-match-error-in-control-plane/253/2 "2022-03-02T00:42:21Z")

</div>

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

See [P4Runtime Specification](https://p4.org/p4-spec/p4runtime/v1.3.0/P4Runtime-Spec.html#sec-match-format). 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](https://p4.org/p4-spec/p4runtime/v1.3.0/P4Runtime-Spec.html#sec-error-reporting-messages)
