• Markos Chandras's avatar
    MIPS: bpf: Fix PKT_TYPE case for big-endian cores · b4fe0ec8
    Markos Chandras authored
    The skb->pkt_type field is defined as follows:
    
    u8 pkt_type:3,
       fclone:2,
       ipvs_property:1,
       peeked:1,
       nf_trace:1
    
    resulting to the following layout in big-endian systems
    
    [pkt_type][fclone][ipvs_propery][peeked][nf_trace]
    ^                                                ^
    |                                                |
    LSB                                             MSB
    
    As a result, the existing code did not work because it was trying to
    match pkt_type == 7 whereas in reality it is 7<<5 on big-endian
    systems.
    
    This has been fixed in the interpreter in
    0dcceabb
    "net: filter: fix SKF_AD_PKTTYPE extension on big-endian"
    
    The fix is to look for 7<<5 on big-endian systems for the pkt_type
    field, and shift by 5 so the packet type will be at the lower 3 bits
    of the A register.
    Signed-off-by: default avatarMarkos Chandras <markos.chandras@imgtec.com>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Daniel Borkmann <dborkman@redhat.com>
    Cc: Alexei Starovoitov <ast@plumgrid.com>
    Cc: netdev@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/7132/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    b4fe0ec8
bpf_jit.c 35.5 KB