github.com/fafucoder/cilium@v1.6.11/pkg/monitor/api/drop.go (about)

     1  // Copyright 2018-2019 Authors of Cilium
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package api
    16  
    17  import (
    18  	"fmt"
    19  )
    20  
    21  // DropMin numbers below this are non-drop reason codes
    22  var DropMin uint8 = 130
    23  
    24  // DropInvalid is the Invalid packet reason.
    25  var DropInvalid uint8 = 2
    26  
    27  var errors = map[uint8]string{
    28  	0:   "Success",
    29  	2:   "Invalid packet",
    30  	3:   "Interface",
    31  	4:   "Interface Decrypted",
    32  	5:   "LB, sock cgroup: No slave entry found",
    33  	6:   "LB, sock cgroup: No backend entry found",
    34  	7:   "LB, sock cgroup: Reverse entry update failed",
    35  	8:   "LB, sock cgroup: Reverse entry stale",
    36  	130: "Invalid source mac",      // Unused
    37  	131: "Invalid destination mac", // Unused
    38  	132: "Invalid source ip",
    39  	133: "Policy denied (L3)",
    40  	134: "Invalid packet",
    41  	135: "CT: Truncated or invalid header",
    42  	136: "CT: Missing TCP ACK flag", // Unused
    43  	137: "CT: Unknown L4 protocol",
    44  	138: "CT: Can't create entry from packet", // Unused
    45  	139: "Unsupported L3 protocol",
    46  	140: "Missed tail call",
    47  	141: "Error writing to packet",
    48  	142: "Unknown L4 protocol",
    49  	143: "Unknown ICMPv4 code",
    50  	144: "Unknown ICMPv4 type",
    51  	145: "Unknown ICMPv6 code",
    52  	146: "Unknown ICMPv6 type",
    53  	147: "Error retrieving tunnel key",
    54  	148: "Error retrieving tunnel options", // Unused
    55  	149: "Invalid Geneve option",           // Unused
    56  	150: "Unknown L3 target address",
    57  	151: "Stale or unroutable IP",
    58  	152: "No matching local container found", // Unused
    59  	153: "Error while correcting L3 checksum",
    60  	154: "Error while correcting L4 checksum",
    61  	155: "CT: Map insertion failed",
    62  	156: "Invalid IPv6 extension header",
    63  	157: "IP fragmentation not supported",
    64  	158: "Service backend not found",
    65  	159: "Policy denied (L4)", // Unused
    66  	160: "No tunnel/encapsulation endpoint (datapath BUG!)",
    67  	161: "Failed to insert into proxymap", // Unused
    68  	162: "Policy denied (CIDR)",           // Unused
    69  	163: "Unknown connection tracking state",
    70  	164: "Local host is unreachable",
    71  	165: "No configuration available to perform policy decision",
    72  	166: "Unsupported L2 protocol",
    73  	167: "No mapping for NAT masquerade",
    74  	168: "Unsupported protocol for NAT masquerade",
    75  	169: "FIB lookup failed",
    76  	170: "Encapsulation traffic is prohibited",
    77  	171: "Invalid identity",
    78  	172: "Unknown sender",
    79  }
    80  
    81  // DropReason prints the drop reason in a human readable string
    82  func DropReason(reason uint8) string {
    83  	if err, ok := errors[reason]; ok {
    84  		return err
    85  	}
    86  	return fmt.Sprintf("%d", reason)
    87  }