Example #1
0
void
test_set_field_IPV6_IP_ECN(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;
  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 1, OFPXMT_OFB_IP_ECN << 1,
            0x03);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0x00,
                            "SET_FIELD IPV6_IP_ECN[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[15], 0x30,
                            "SET_FIELD IPV6_IP_ECN[1] error.");
}
Example #2
0
void
test_push_vlan(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_push *action_push;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) +
                  sizeof(*action_push) - sizeof(struct ofp_action_header));
  action_push = (struct ofp_action_push *)&action->ofpat;
  action_push->type = OFPAT_PUSH_VLAN;
  action_push->ethertype = 0x8100;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x45;

  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 4,
                            "PUSH_VLAN length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x81,
                            "PUSH_VLAN TPID[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x00,
                            "PUSH_VLAN TPID[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0x08,
                            "PUSH_VLAN ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 0x00,
                            "PUSH_VLAN ethertype[1] error.");

  OS_MTOD(m, uint8_t *)[14] = 0xef;
  OS_MTOD(m, uint8_t *)[15] = 0xfe;
  action_push->ethertype = 0x88a8;
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 8,
                            "PUSH_VLAN(2) length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x88,
                            "PUSH_VLAN(2) TPID[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0xa8,
                            "PUSH_VLAN(2) TPID[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0xef,
                            "PUSH_VLAN(2) TCI[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[15], 0xfe,
                            "PUSH_VLAN(2) TCI[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0x81,
                            "PUSH_VLAN(2) ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 0x00,
                            "PUSH_VLAN(2) ethertype[1] error.");
}
Example #3
0
void
test_classify_packet_MPLSMC(void) {
  struct port port;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);
  OS_M_PKTLEN(m) = 128;

  OS_MTOD(m, uint8_t *)[12] = 0x88;
  OS_MTOD(m, uint8_t *)[13] = 0x48;

  lagopus_packet_init(pkt, m, &port);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_MPLS_MCAST,
                            "ether_type error.");
  /* with VLAN */
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x88;
  OS_MTOD(m, uint8_t *)[17] = 0x48;

  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_MPLS_MCAST,
                            "ether_type(vlan) error.");
}
Example #4
0
void
test_match_basic_IPV4_PROTO(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;
  OS_M_APPEND(m, 64);

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

  add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x08, 0x00);

  /* IP proto */
  add_match(&flow->match_list, 1, OFPXMT_OFB_IP_PROTO << 1,
            IPPROTO_TCP);

  refresh_match(flow);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x45;

  OS_MTOD(m, uint8_t *)[23] = IPPROTO_UDP;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IP_PROTO mismatch error.");
  OS_MTOD(m, uint8_t *)[23] = IPPROTO_TCP;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "IP_PROTO match error.");
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x08;
  OS_MTOD(m, uint8_t *)[17] = 0x00;
  OS_MTOD(m, uint8_t *)[18] = 0x45;

  OS_MTOD(m, uint8_t *)[27] = IPPROTO_UDP;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IP_PROTO mismatch(vlan) error.");
  OS_MTOD(m, uint8_t *)[27] = IPPROTO_TCP;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "IP_PROTO match(vlan) error.");
  free(m);
}
Example #5
0
void
test_match_basic_IPV4_SRC(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;
  OS_M_APPEND(m, 64);

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

  add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x08, 0x00);
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x08;
  OS_MTOD(m, uint8_t *)[17] = 0x00;
  OS_MTOD(m, uint8_t *)[18] = 0x45;
  /* IP src */
  add_match(&flow->match_list, 4, OFPXMT_OFB_IPV4_SRC << 1,
            192, 168, 0, 1);
  OS_MTOD(m, uint8_t *)[30] = 192;
  OS_MTOD(m, uint8_t *)[31] = 167;
  OS_MTOD(m, uint8_t *)[32] = 0;
  OS_MTOD(m, uint8_t *)[33] = 1;
  refresh_match(flow);
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IPV4_SRC mismatch(1) error.");
  add_match(&flow->match_list, 4, OFPXMT_OFB_IPV4_SRC << 1,
            192, 168, 0, 1);
  refresh_match(flow);
  OS_MTOD(m, uint8_t *)[30] = 1;
  OS_MTOD(m, uint8_t *)[31] = 0;
  OS_MTOD(m, uint8_t *)[32] = 168;
  OS_MTOD(m, uint8_t *)[33] = 192;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IPV4_SRC mismatch(2) error.");
  OS_MTOD(m, uint8_t *)[30] = 192;
  OS_MTOD(m, uint8_t *)[31] = 168;
  OS_MTOD(m, uint8_t *)[32] = 0;
  OS_MTOD(m, uint8_t *)[33] = 1;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "IPV4_SRC match error.");
  free(m);
}
Example #6
0
void
test_match_basic_IPV6_ND_TLL(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;
  int i;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;
  OS_M_PKTLEN(m) = 128;

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

  add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x86, 0xdd);

  /* IP proto */
  add_match(&flow->match_list, 1, OFPXMT_OFB_IP_PROTO << 1,
            IPPROTO_ICMPV6);

  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;
  OS_MTOD(m, uint8_t *)[19] = 0x80; /* PLEN */
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_ICMPV6;
  OS_MTOD(m, uint8_t *)[54] = ND_NEIGHBOR_ADVERT;
  OS_MTOD(m, uint8_t *)[78] = ND_OPT_SOURCE_LINKADDR;
  OS_MTOD(m, uint8_t *)[79] = 1;
  OS_MTOD(m, uint8_t *)[86] = ND_OPT_TARGET_LINKADDR;
  OS_MTOD(m, uint8_t *)[87] = 1;
  add_match(&flow->match_list, ETH_ALEN, OFPXMT_OFB_IPV6_ND_TLL << 1,
            0xe0, 0x4d, 0x01, 0x34, 0x56, 0x78);
  refresh_match(flow);
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IPV6_ND_TLL mismatch error.");
  i = 88;
  OS_MTOD(m, uint8_t *)[i++] = 0xe0;
  OS_MTOD(m, uint8_t *)[i++] = 0x4d;
  OS_MTOD(m, uint8_t *)[i++] = 0x01;
  OS_MTOD(m, uint8_t *)[i++] = 0x34;
  OS_MTOD(m, uint8_t *)[i++] = 0x56;
  OS_MTOD(m, uint8_t *)[i++] = 0x78;
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "IPV6_ND_TLL match error.");
}
Example #7
0
void
test_pop_pbb(void) {
  static const uint8_t odhost[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab };
  static const uint8_t oshost[] = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54 };
  static const uint8_t idhost[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
  static const uint8_t ishost[] = { 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb };
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_pop_mpls *action_pop;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action));
  action_pop = (struct ofp_action_pop_mpls *)&action->ofpat;
  action_pop->type = OFPAT_POP_PBB;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);

  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64 + 18);
  OS_MEMCPY(&OS_MTOD(m, uint8_t *)[0], odhost, ETH_ALEN);
  OS_MEMCPY(&OS_MTOD(m, uint8_t *)[6], oshost, ETH_ALEN);
  OS_MTOD(m, uint8_t *)[12] = 0x88;
  OS_MTOD(m, uint8_t *)[13] = 0xe7;
  OS_MTOD(m, uint8_t *)[14] = 0x00;
  OS_MTOD(m, uint8_t *)[15] = 0x11;
  OS_MTOD(m, uint8_t *)[16] = 0x22;
  OS_MTOD(m, uint8_t *)[17] = 0x33;
  /* dhost and shost */
  OS_MEMCPY(&OS_MTOD(m, uint8_t *)[18], idhost, ETH_ALEN);
  OS_MEMCPY(&OS_MTOD(m, uint8_t *)[24], ishost, ETH_ALEN);
  OS_MTOD(m, uint8_t *)[30] = 0x08;
  OS_MTOD(m, uint8_t *)[31] = 0x00;
  OS_MTOD(m, uint8_t *)[32] = 0x45;

  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64,
                            "POP_PBB length error.");
  TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(&OS_MTOD(m, uint8_t *)[0], idhost, ETH_ALEN,
                                        "POP_PBB ether_dhost error.");
  TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(&OS_MTOD(m, uint8_t *)[6], ishost, ETH_ALEN,
                                        "POP_PBB ether_shost error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x08,
                            "POP_PBB ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x00,
                            "POP_PBB ethertype[1] error.");
}
Example #8
0
void
test_classify_packet_PBB(void) {
  struct port port;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);
  OS_M_PKTLEN(m) = 128;

#ifdef PBB_IS_VLAN
  OS_MTOD(m, uint8_t *)[12] = 0x88;
  OS_MTOD(m, uint8_t *)[13] = 0xe7;
  OS_MTOD(m, uint8_t *)[30] = 0x08;
  OS_MTOD(m, uint8_t *)[31] = 0x00;

  lagopus_packet_init(pkt, m, &port);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IP,
                            "ether_type error.");
  /* with VLAN */
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x88;
  OS_MTOD(m, uint8_t *)[17] = 0xe7;
  OS_MTOD(m, uint8_t *)[34] = 0x08;
  OS_MTOD(m, uint8_t *)[35] = 0x00;

  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IP,
                            "ether_type(vlan) error.");
#else
  OS_MTOD(m, uint8_t *)[12] = 0x88;
  OS_MTOD(m, uint8_t *)[13] = 0xe7;

  lagopus_packet_init(pkt, m, &port);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_PBB,
                            "ether_type error.");
  /* with VLAN */
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x88;
  OS_MTOD(m, uint8_t *)[17] = 0xe7;

  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_PBB,
                            "ether_type(vlan) error.");
#endif
}
void
test_set_field_ARP_THA(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);

  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x06;
  OS_MTOD(m, uint8_t *)[20] = 0x00;
  OS_MTOD(m, uint8_t *)[21] = ARPOP_REQUEST;
  OS_MTOD(m, uint8_t *)[32] = 0xaa;
  OS_MTOD(m, uint8_t *)[33] = 0x55;
  OS_MTOD(m, uint8_t *)[34] = 0xaa;
  OS_MTOD(m, uint8_t *)[35] = 0x55;
  OS_MTOD(m, uint8_t *)[36] = 0xaa;
  OS_MTOD(m, uint8_t *)[37] = 0x55;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 6, OFPXMT_OFB_ARP_THA << 1,
            0xe0, 0x4d, 0x01, 0x34, 0x56, 0x78);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[32], 0xe0,
                            "SET_FIELD ARP_THA[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[33], 0x4d,
                            "SET_FIELD ARP_THA[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[34], 0x01,
                            "SET_FIELD ARP_THA[2] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[35], 0x34,
                            "SET_FIELD ARP_THA[3] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[36], 0x56,
                            "SET_FIELD ARP_THA[4] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[37], 0x78,
                            "SET_FIELD ARP_THA[5] error.");
}
Example #10
0
void
test_set_field_IPV6_SCTP_DST(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_PKTLEN(m) = 128;
  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_SCTP;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 2, OFPXMT_OFB_SCTP_DST << 1,
            0x80, 0x21);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[56], 0x80,
                            "SET_FIELD IPV6_SCTP_DST[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[57], 0x21,
                            "SET_FIELD IPV6_SCTP_DST[1] error.");
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_DSTOPTS;
  OS_MTOD(m, uint8_t *)[54] = IPPROTO_SCTP;
  OS_MTOD(m, uint8_t *)[55] = 0;
  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[54], IPPROTO_SCTP,
                            "SET_FIELD IPV6_SCTP_DST proto error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[64], 0x80,
                            "SET_FIELD IPV6_SCTP_DST[0](next hdr) error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[65], 0x21,
                            "SET_FIELD IPV6_SCTP_DST[1](next hdr) error.");
}
Example #11
0
void
test_match_basic_PBB_ISID_W(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);
  OS_M_APPEND(m, 64);

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

#ifndef PBB_IS_VLAN
  add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x88, 0xe7);
#endif
  OS_MTOD(m, uint8_t *)[12] = 0x88;
  OS_MTOD(m, uint8_t *)[13] = 0xe7;
  add_match(&flow->match_list, 6, (OFPXMT_OFB_PBB_ISID << 1) + 1,
            0x5a, 0xc3, 0x00, 0xff, 0xff, 0x00);
  refresh_match(flow);
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "PBB_ISID_W mismatch(1) error.");
  OS_MTOD(m, uint8_t *)[15] = 0x3c;
  OS_MTOD(m, uint8_t *)[16] = 0xc3;
  OS_MTOD(m, uint8_t *)[17] = 0x5a;
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "PBB_ISID_W mismatch(2) error.");
  OS_MTOD(m, uint8_t *)[15] = 0x5a;
  OS_MTOD(m, uint8_t *)[16] = 0xc3;
  OS_MTOD(m, uint8_t *)[17] = 0x3c;
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "PBB_ISID_W match error.");
}
Example #12
0
void
test_pop_vlan(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_pop_mpls *action_pop;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action));
  action_pop = (struct ofp_action_pop_mpls *)&action->ofpat;
  action_pop->type = OFPAT_POP_VLAN;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64 + 4);
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x30;
  OS_MTOD(m, uint8_t *)[15] = 50;
  OS_MTOD(m, uint8_t *)[16] = 0x08;
  OS_MTOD(m, uint8_t *)[17] = 0x00;
  OS_MTOD(m, uint8_t *)[18] = 0x45;
  OS_MTOD(m, uint8_t *)[26] = 240;

  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64,
                            "POP_VLAN length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x08,
                            "POP_VLAN ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x00,
                            "POP_VLAN ethertype[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0x45,
                            "POP_VLAN ip_vhl error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[22], 240,
                            "POP_VLAN ip_ttl error.");
}
Example #13
0
void
test_set_field_ETH_TYPE(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);

  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x20, 0xf1);
  execute_action(pkt, &action_list);

  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x20,
                            "SET_FIELD ETH_TYPE[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0xf1,
                            "SET_FIELD ETH_TYPE[1] error.");
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;

  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);

  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0x20,
                            "SET_FIELD(vlan) ETH_TYPE[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 0xf1,
                            "SET_FIELD(vlan) ETH_TYPE[1] error.");
}
void
test_set_field_ARP_SPA(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x06;
  OS_MTOD(m, uint8_t *)[20] = 0x00;
  OS_MTOD(m, uint8_t *)[21] = ARPOP_REQUEST;
  OS_MTOD(m, uint8_t *)[28] = 172;
  OS_MTOD(m, uint8_t *)[29] = 21;
  OS_MTOD(m, uint8_t *)[30] = 0;
  OS_MTOD(m, uint8_t *)[31] = 1;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 4, OFPXMT_OFB_ARP_SPA << 1,
            192, 168, 1, 2);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[28], 192,
                            "SET_FIELD ARP_SPA[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[29], 168,
                            "SET_FIELD ARP_SPA[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[30], 1,
                            "SET_FIELD ARP_SPA[2] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[31], 2,
                            "SET_FIELD ARP_SPA[3] error.");
}
Example #15
0
/**
 * Copy packet for output.
 */
struct lagopus_packet *
copy_packet(struct lagopus_packet *src_pkt) {
  struct rte_mbuf *mbuf;
  struct lagopus_packet *pkt;
  size_t pktlen;

  pkt = alloc_lagopus_packet();
  if (pkt == NULL) {
    lagopus_msg_error("alloc_lagopus_packet failed\n");
    return NULL;
  }
  mbuf = pkt->mbuf;
  pktlen = OS_M_PKTLEN(src_pkt->mbuf);
  OS_M_APPEND(mbuf, pktlen);
  memcpy(OS_MTOD(pkt->mbuf, char *), OS_MTOD(src_pkt->mbuf, char *), pktlen);
  pkt->in_port = src_pkt->in_port;
  /* other pkt members are not used in physical output. */
  return pkt;
}
Example #16
0
void
test_set_field_ETH_SRC(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 6, OFPXMT_OFB_ETH_SRC << 1,
            0x22, 0x44, 0x66, 0x88, 0xaa, 0xcc);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[6], 0x22,
                            "SET_FIELD ETH_SRC[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[7], 0x44,
                            "SET_FIELD ETH_SRC[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[8], 0x66,
                            "SET_FIELD ETH_SRC[2] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[9], 0x88,
                            "SET_FIELD ETH_SRC[3] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[10], 0xaa,
                            "SET_FIELD ETH_SRC[4] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[11], 0xcc,
                            "SET_FIELD ETH_SRC[5] error.");
}
Example #17
0
void
test_set_field_ETH_DST(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 6, OFPXMT_OFB_ETH_DST << 1,
            0x23, 0x45, 0x67, 0x89, 0xab, 0xcd);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[0], 0x23,
                            "SET_FIELD ETH_DST[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[1], 0x45,
                            "SET_FIELD ETH_DST[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[2], 0x67,
                            "SET_FIELD ETH_DST[2] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[3], 0x89,
                            "SET_FIELD ETH_DST[3] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[4], 0xab,
                            "SET_FIELD ETH_DST[4] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[5], 0xcd,
                            "SET_FIELD ETH_DST[5] error.");
}
Example #18
0
void
test_set_field_ICMPV6_TYPE(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_ICMPV6;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 2, OFPXMT_OFB_ICMPV6_TYPE << 1,
            ICMP6_ECHO_REQUEST);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[54], ICMP6_ECHO_REQUEST,
                            "SET_FIELD ICMPV6_TYPE error.");
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_DSTOPTS;
  OS_MTOD(m, uint8_t *)[54] = IPPROTO_ICMPV6;
  OS_MTOD(m, uint8_t *)[55] = 0;
  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[54], IPPROTO_ICMPV6,
                            "SET_FIELD ICMPV6_TYPE proto error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[62], ICMP6_ECHO_REQUEST,
                            "SET_FIELD ICMPV6_TYPE(next hdr) error.");
}
Example #19
0
void
test_classify_packet_IPV6_other(void) {
  struct port port;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);
  OS_M_APPEND(m, 64);

  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_RSVP;

  lagopus_packet_init(pkt, m, &port);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IPV6,
                            "ether_type error.");
  /* with exthdr */
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_DSTOPTS;
  OS_MTOD(m, uint8_t *)[54] = IPPROTO_RSVP;
  OS_MTOD(m, uint8_t *)[55] = 0;
  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IPV6,
                            "ether_type(exthdr) error.");
  /* with VLAN */
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x86;
  OS_MTOD(m, uint8_t *)[17] = 0xdd;
  OS_MTOD(m, uint8_t *)[24] = IPPROTO_RSVP;
  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IPV6,
                            "ether_type(vlan) error.");
  /* with VLAN and exthdr */
  OS_MTOD(m, uint8_t *)[24] = IPPROTO_DSTOPTS;
  OS_MTOD(m, uint8_t *)[58] = IPPROTO_RSVP;
  OS_MTOD(m, uint8_t *)[59] = 0;
  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IPV6,
                            "ether_type(vlan+exthdr) error.");
}
Example #20
0
void
test_classify_packet_IPV4_UDP(void) {
  struct port port;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);
  OS_M_PKTLEN(m) = 128;

  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x45;
  OS_MTOD(m, uint8_t *)[23] = IPPROTO_UDP;

  lagopus_packet_init(pkt, m, &port);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IP,
                            "ether_type error.");
  TEST_ASSERT_EQUAL_MESSAGE(pkt->l3_hdr, &OS_MTOD(m, uint8_t *)[14],
                            "l3_hdr error.");
  TEST_ASSERT_EQUAL_MESSAGE(pkt->l4_hdr, &OS_MTOD(m, uint8_t *)[34],
                            "l4_hdr error.");
  /* with VLAN */
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[16] = 0x08;
  OS_MTOD(m, uint8_t *)[17] = 0x00;
  OS_MTOD(m, uint8_t *)[18] = 0x45;
  OS_MTOD(m, uint8_t *)[27] = IPPROTO_UDP;

  classify_ether_packet(pkt);
  TEST_ASSERT_EQUAL_MESSAGE(pkt->ether_type, ETHERTYPE_IP,
                            "ether_type(vlan) error.");
  TEST_ASSERT_EQUAL_MESSAGE(pkt->l3_hdr, &OS_MTOD(m, uint8_t *)[18],
                            "l3_hdr(vlan) error.");
  TEST_ASSERT_EQUAL_MESSAGE(pkt->l4_hdr, &OS_MTOD(m, uint8_t *)[38],
                            "l4_hdr(vlan) error.");
}
Example #21
0
void
test_match_basic_VLAN_VID_W(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);
  OS_M_APPEND(m, 64);

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

  /* VLAN VID_NONE */
  add_match(&flow->match_list, 4, (OFPXMT_OFB_VLAN_VID << 1) + 1,
            0x10, 0x00, 0x10, 0x00);
  refresh_match(flow);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "VLAN_VID_W mismatch error.");
  OS_MTOD(m, uint8_t *)[12] = 0x81;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x00;
  OS_MTOD(m, uint8_t *)[15] = 0xff;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "VLAN VID_W match error.");
  free(m);
}
Example #22
0
void
test_match_basic_IPV4_IP_ECN(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;
  OS_M_APPEND(m, 64);

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

  add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x08, 0x00);
  refresh_match(flow);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x45;
  add_match(&flow->match_list, 1, OFPXMT_OFB_IP_ECN << 1,
            0x3);
  OS_MTOD(m, uint8_t *)[15] = 0xcc;
  refresh_match(flow);
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IP_ECN mismatch error.");
  OS_MTOD(m, uint8_t *)[15] = 0x03;
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "IP_ECN match error.");
}
Example #23
0
void
test_set_field_IPV6_DST(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_set_field *action_set;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) + 64);
  action_set = (struct ofp_action_set_field *)&action->ofpat;
  action_set->type = OFPAT_SET_FIELD;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = PKT2MBUF(pkt);

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;

  lagopus_packet_init(pkt, m, &port);
  set_match(action_set->field, 16, OFPXMT_OFB_IPV6_DST << 1,
            0x20, 0x01, 0x00, 0x00, 0xe0, 0x45, 0x22, 0xeb,
            0x09, 0x00, 0x00, 0x08, 0xdc, 0x18, 0x94, 0xad);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[38], 0x20,
                            "SET_FIELD IPV6_DST[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[39], 0x01,
                            "SET_FIELD IPV6_DST[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[40], 0x00,
                            "SET_FIELD IPV6_DST[2] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[41], 0x00,
                            "SET_FIELD IPV6_DST[3] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[42], 0xe0,
                            "SET_FIELD IPV6_DST[4] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[43], 0x45,
                            "SET_FIELD IPV6_DST[5] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[44], 0x22,
                            "SET_FIELD IPV6_DST[6] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[45], 0xeb,
                            "SET_FIELD IPV6_DST[7] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[46], 0x09,
                            "SET_FIELD IPV6_DST[8] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[47], 0x00,
                            "SET_FIELD IPV6_DST[9] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[48], 0x00,
                            "SET_FIELD IPV6_DST[10] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[49], 0x08,
                            "SET_FIELD IPV6_DST[11] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[50], 0xdc,
                            "SET_FIELD IPV6_DST[12] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[51], 0x18,
                            "SET_FIELD IPV6_DST[13] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[52], 0x94,
                            "SET_FIELD IPV6_DST[14] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[53], 0xad,
                            "SET_FIELD IPV6_DST[15] error.");
}
Example #24
0
void
test_lagopus_find_flow(void) {
    datastore_bridge_info_t info;
    struct bridge *bridge;
    struct port *port;
    struct port nport;
    struct lagopus_packet *pkt;
    struct table *table;
    struct flow *flow;
    OS_MBUF *m;

    /* setup bridge and port */
    memset(&info, 0, sizeof(info));
    info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
    TEST_ASSERT_EQUAL(dp_bridge_create("br0", &info), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_port_create("port0"), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_port_create("port1"), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_bridge_port_set("br0", "port0", 1), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_bridge_port_set("br0", "port1", 2), LAGOPUS_RESULT_OK);

    pkt = alloc_lagopus_packet();
    TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
    m = pkt->mbuf;
    OS_M_APPEND(m, 64);
    m->refcnt = 2;

    bridge = dp_bridge_lookup("br0");
    TEST_ASSERT_NOT_NULL(bridge);
    lagopus_packet_init(pkt, m, port_lookup(&bridge->ports, 1));
    table = flowdb_get_table(pkt->in_port->bridge->flowdb, 0);
    table->userdata = new_flowinfo_eth_type();
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(misc) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(misc) error.");
    OS_MTOD(m, uint8_t *)[14] = 0x08;
    OS_MTOD(m, uint8_t *)[15] = 0x06;
    lagopus_packet_init(pkt, m, &port);
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(arp) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(arp) error.");
    OS_MTOD(m, uint8_t *)[14] = 0x08;
    OS_MTOD(m, uint8_t *)[15] = 0x00;
    lagopus_packet_init(pkt, m, port_lookup(&bridge->ports, 1));
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(ipv4) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(ipv4) error.");
    OS_MTOD(m, uint8_t *)[14] = 0x86;
    OS_MTOD(m, uint8_t *)[15] = 0xdd;
    OS_MTOD(m, uint8_t *)[20] = IPPROTO_TCP;
    lagopus_packet_init(pkt, m, port_lookup(&bridge->ports, 1));
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(ipv6) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(ipv6) error.");
    OS_MTOD(m, uint8_t *)[14] = 0x88;
    OS_MTOD(m, uint8_t *)[15] = 0x47;
    lagopus_packet_init(pkt, m, port_lookup(&bridge->ports, 1));
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(mpls) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(mpls) error.");
    OS_MTOD(m, uint8_t *)[14] = 0x88;
    OS_MTOD(m, uint8_t *)[15] = 0x48;
    lagopus_packet_init(pkt, m, port_lookup(&bridge->ports, 1));
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(mpls-mc) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(mpls-mc) error.");
    OS_MTOD(m, uint8_t *)[14] = 0x88;
    OS_MTOD(m, uint8_t *)[15] = 0xe7;
    lagopus_packet_init(pkt, m, port_lookup(&bridge->ports, 1));
    flow = lagopus_find_flow(pkt, table);
    TEST_ASSERT_EQUAL_MESSAGE(table->lookup_count, 0,
                              "lookup_count(pbb) error.");
    TEST_ASSERT_NULL_MESSAGE(flow,
                             "flow(pbb) error.");
}
Example #25
0
void
test_push_mpls(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_push *action_push;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) +
                  sizeof(*action_push) - sizeof(struct ofp_action_header));
  action_push = (struct ofp_action_push *)&action->ofpat;
  action_push->type = OFPAT_PUSH_MPLS;
  action_push->ethertype = 0x8847;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64);
  OS_MTOD(m, uint8_t *)[12] = 0x08;
  OS_MTOD(m, uint8_t *)[13] = 0x00;
  OS_MTOD(m, uint8_t *)[14] = 0x45;
  OS_MTOD(m, uint8_t *)[22] = 240;

  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 4,
                            "PUSH_MPLS length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x88,
                            "PUSH_MPLS ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x47,
                            "PUSH_MPLS ethertype[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 1,
                            "PUSH_MPLS BOS error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 240,
                            "PUSH_MPLS TTL error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[18], 0x45,
                            "PUSH_MPLS payload error.");

  OS_MTOD(m, uint8_t *)[14] = 0x12;
  OS_MTOD(m, uint8_t *)[15] = 0x34;
  OS_MTOD(m, uint8_t *)[16] = 0x5f;

  action_push->ethertype = 0x8848;
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 8,
                            "PUSH_MPLS(2) length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x88,
                            "PUSH_MPLS(2) ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x48,
                            "PUSH_MPLS(2) ethertype[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0x12,
                            "PUSH_MPLS(2) LSE[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[15], 0x34,
                            "PUSH_MPLS(2) LSE[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0x5e,
                            "PUSH_MPLS(2) LSE[2] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 240,
                            "PUSH_MPLS(2) LSE[3] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[18], 0x12,
                            "PUSH_MPLS(2) payload[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[19], 0x34,
                            "PUSH_MPLS(2) payload[1] error.");
}
Example #26
0
void
test_match_basic_IPV6_ND_TARGET(void) {
  struct lagopus_packet *pkt;
  struct port port;
  struct flow *flow;
  OS_MBUF *m;
  bool rv;
  int i;

  /* prepare packet */
  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;
  OS_M_PKTLEN(m) = 128;

  /* prepare flow */
  flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
  TAILQ_INIT(&flow->match_list);

  add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
            0x86, 0xdd);

  /* IP proto */
  add_match(&flow->match_list, 1, OFPXMT_OFB_IP_PROTO << 1,
            IPPROTO_ICMPV6);

  OS_MTOD(m, uint8_t *)[12] = 0x86;
  OS_MTOD(m, uint8_t *)[13] = 0xdd;
  OS_MTOD(m, uint8_t *)[20] = IPPROTO_ICMPV6;
  OS_MTOD(m, uint8_t *)[54] = ND_NEIGHBOR_SOLICIT;
  add_match(&flow->match_list, 16, OFPXMT_OFB_IPV6_ND_TARGET << 1,
            0x20, 0x01, 0x00, 0x00, 0xe0, 0x45, 0x22, 0xeb,
            0x09, 0x00, 0x00, 0x08, 0xdc, 0x18, 0x94, 0xad);
  refresh_match(flow);
  i = 62;
  OS_MTOD(m, uint8_t *)[i++] = 0x20;
  OS_MTOD(m, uint8_t *)[i++] = 0x01;
  OS_MTOD(m, uint8_t *)[i++] = 0x20;
  OS_MTOD(m, uint8_t *)[i++] = 0xff;
  OS_MTOD(m, uint8_t *)[i++] = 0x00;
  OS_MTOD(m, uint8_t *)[i++] = 0x00;
  OS_MTOD(m, uint8_t *)[i++] = 0x10;
  OS_MTOD(m, uint8_t *)[i++] = 0x20;
  OS_MTOD(m, uint8_t *)[i++] = 0x11;
  OS_MTOD(m, uint8_t *)[i++] = 0xe1;
  OS_MTOD(m, uint8_t *)[i++] = 0x50;
  OS_MTOD(m, uint8_t *)[i++] = 0x89;
  OS_MTOD(m, uint8_t *)[i++] = 0xbf;
  OS_MTOD(m, uint8_t *)[i++] = 0xc6;
  OS_MTOD(m, uint8_t *)[i++] = 0x43;
  OS_MTOD(m, uint8_t *)[i++] = 0x11;
  lagopus_packet_init(pkt, m, &port);
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, false,
                            "IPV6_ND_TARGET mismatch error.");
  i = 62;
  OS_MTOD(m, uint8_t *)[i++] = 0x20;
  OS_MTOD(m, uint8_t *)[i++] = 0x01;
  OS_MTOD(m, uint8_t *)[i++] = 0x00;
  OS_MTOD(m, uint8_t *)[i++] = 0x00;
  OS_MTOD(m, uint8_t *)[i++] = 0xe0;
  OS_MTOD(m, uint8_t *)[i++] = 0x45;
  OS_MTOD(m, uint8_t *)[i++] = 0x22;
  OS_MTOD(m, uint8_t *)[i++] = 0xeb;
  OS_MTOD(m, uint8_t *)[i++] = 0x09;
  OS_MTOD(m, uint8_t *)[i++] = 0x00;
  OS_MTOD(m, uint8_t *)[i++] = 0x00;
  OS_MTOD(m, uint8_t *)[i++] = 0x08;
  OS_MTOD(m, uint8_t *)[i++] = 0xdc;
  OS_MTOD(m, uint8_t *)[i++] = 0x18;
  OS_MTOD(m, uint8_t *)[i++] = 0x94;
  OS_MTOD(m, uint8_t *)[i++] = 0xad;
  rv = match_basic(pkt, flow);
  TEST_ASSERT_EQUAL_MESSAGE(rv, true,
                            "IPV6_ND_TARGET match error.");
}
Example #27
0
void
test_push_pbb(void) {
  static const uint8_t dhost[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
  static const uint8_t shost[] = { 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb };
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_push *action_push;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) +
                  sizeof(*action_push) - sizeof(struct ofp_action_header));
  action_push = (struct ofp_action_push *)&action->ofpat;
  action_push->type = OFPAT_PUSH_PBB;
  action_push->ethertype = 0x88e7;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64);
  OS_MEMCPY(&OS_MTOD(m, uint8_t *)[0], dhost, ETH_ALEN);
  OS_MEMCPY(&OS_MTOD(m, uint8_t *)[6], shost, ETH_ALEN);

  lagopus_packet_init(pkt, m, &port);
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 18,
                            "PUSH_PBB length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x88,
                            "PUSH_PBB TPID[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0xe7,
                            "PUSH_PBB TPID[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0,
                            "PUSH_PBB pcp_dei error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[15], 0x00,
                            "PUSH_PBB i_sid[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0x00,
                            "PUSH_PBB i_sid[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 0x00,
                            "PUSH_PBB i_sid[2] error.");
  TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(&OS_MTOD(m, uint8_t *)[18], dhost, ETH_ALEN,
                                        "PUSH_PBB dhost error.");
  TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(&OS_MTOD(m, uint8_t *)[24], shost, ETH_ALEN,
                                        "PUSH_PBB shost error.");
  OS_MTOD(m, uint8_t *)[15] = 0xab;
  OS_MTOD(m, uint8_t *)[16] = 0xcd;
  OS_MTOD(m, uint8_t *)[17] = 0xef;
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 18 + 18,
                            "PUSH_PBB length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[15], 0xab,
                            "PUSH_PBB(2) i_sid[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0xcd,
                            "PUSH_PBB(2) i_sid[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 0xef,
                            "PUSH_PBB(2) i_sid[2] error.");
}
Example #28
0
void
test_pop_mpls(void) {
  struct port port;
  struct action_list action_list;
  struct action *action;
  struct ofp_action_pop_mpls *action_pop;
  struct lagopus_packet *pkt;
  OS_MBUF *m;

  TAILQ_INIT(&action_list);
  action = calloc(1, sizeof(*action) +
                  sizeof(*action_pop) - sizeof(struct ofp_action_header));
  action_pop = (struct ofp_action_pop_mpls *)&action->ofpat;
  action_pop->type = OFPAT_POP_MPLS;
  lagopus_set_action_function(action);
  TAILQ_INSERT_TAIL(&action_list, action, entry);


  pkt = alloc_lagopus_packet();
  TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
  m = pkt->mbuf;

  OS_M_APPEND(m, 64 + 8);
  /* initial, double taged */
  OS_MTOD(m, uint8_t *)[12] = 0x88;
  OS_MTOD(m, uint8_t *)[13] = 0x48;
  /* outer LSE */
  OS_MTOD(m, uint8_t *)[17] = 50;
  /* innner LSE */
  OS_MTOD(m, uint8_t *)[20] = 0x01;
  OS_MTOD(m, uint8_t *)[21] = 100;
  /* IPv4 */
  OS_MTOD(m, uint8_t *)[22] = 0x45;
  OS_MTOD(m, uint8_t *)[30] = 240;

  lagopus_packet_init(pkt, m, &port);
  action_pop->ethertype = 0x8847;
  TEST_ASSERT_EQUAL(execute_action(pkt, &action_list), LAGOPUS_RESULT_OK);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64 + 4,
                            "POP_MPLS length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x88,
                            "POP_MPLS ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x47,
                            "POP_MPLS ethertype[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 1,
                            "POP_MPLS BOS error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 100,
                            "POP_MPLS TTL error.");
  action_pop->ethertype = 0x0800;
  execute_action(pkt, &action_list);
  TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64,
                            "POP_MPLS(2) length error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x08,
                            "POP_MPLS(2) ethertype[0] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x00,
                            "POP_MPLS(2) ethertype[1] error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0x45,
                            "POP_MPLS(2) ip_vhl error.");
  TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[22], 240,
                            "POP_MPLS(2) ip_ttl error.");
}