when packet be claimed, clean the packet exdata
This commit is contained in:
@@ -24,14 +24,10 @@ struct metadata
|
||||
{
|
||||
struct route_ctx route_ctx;
|
||||
struct sids sids;
|
||||
|
||||
uint64_t session_id;
|
||||
uint64_t domain;
|
||||
uint16_t link_id;
|
||||
bool is_claim;
|
||||
|
||||
enum packet_direction direction;
|
||||
enum packet_action action;
|
||||
struct timeval tv;
|
||||
};
|
||||
|
||||
@@ -78,6 +74,7 @@ struct packet
|
||||
int8_t layers_size;
|
||||
int8_t need_free;
|
||||
int8_t is_defraged;
|
||||
int8_t is_claim;
|
||||
|
||||
const char *data_ptr;
|
||||
uint16_t data_len;
|
||||
@@ -90,6 +87,7 @@ struct packet
|
||||
|
||||
struct metadata meta;
|
||||
enum packet_type type;
|
||||
enum packet_action action;
|
||||
struct packet_origin origin;
|
||||
};
|
||||
|
||||
@@ -109,9 +107,6 @@ enum packet_load_balance_method
|
||||
void packet_set_route_ctx(struct packet *pkt, const struct route_ctx *ctx);
|
||||
const struct route_ctx *packet_get_route_ctx(const struct packet *pkt);
|
||||
|
||||
void packet_set_origin(struct packet *pkt, struct packet_origin *origin);
|
||||
struct packet_origin *packet_get_origin(struct packet *pkt);
|
||||
|
||||
void packet_set_sids(struct packet *pkt, const struct sids *sids);
|
||||
const struct sids *packet_get_sids(const struct packet *pkt);
|
||||
|
||||
@@ -124,14 +119,8 @@ uint64_t packet_get_domain(const struct packet *pkt);
|
||||
void packet_set_link_id(struct packet *pkt, uint16_t id);
|
||||
uint16_t packet_get_link_id(const struct packet *pkt);
|
||||
|
||||
void packet_set_claim(struct packet *pkt, bool claim);
|
||||
bool packet_is_claim(const struct packet *pkt);
|
||||
|
||||
void packet_set_direction(struct packet *pkt, enum packet_direction dir);
|
||||
|
||||
void *packet_get_user_data(struct packet *pkt);
|
||||
void packet_set_user_data(struct packet *pkt, void *data);
|
||||
|
||||
/******************************************************************************
|
||||
* tuple uitls
|
||||
******************************************************************************/
|
||||
@@ -180,6 +169,15 @@ void packet_set_defraged(struct packet *pkt);
|
||||
void packet_push_frag(struct packet *pkt, struct packet *frag);
|
||||
struct packet *packet_pop_frag(struct packet *pkt);
|
||||
|
||||
void packet_set_claim(struct packet *pkt, bool claim);
|
||||
bool packet_is_claim(const struct packet *pkt);
|
||||
|
||||
void *packet_get_user_data(struct packet *pkt);
|
||||
void packet_set_user_data(struct packet *pkt, void *data);
|
||||
|
||||
void packet_set_origin(struct packet *pkt, struct packet_origin *origin);
|
||||
struct packet_origin *packet_get_origin(struct packet *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -357,6 +357,9 @@ void packet_manager_dispatch(struct packet_manager *pkt_mgr, uint16_t thread_id)
|
||||
{
|
||||
if (pkt_mgr_rte->claim_cb)
|
||||
{
|
||||
struct exdata_runtime *ex_rte = packet_get_user_data(pkt);
|
||||
exdata_runtime_reset(ex_rte);
|
||||
|
||||
pkt_mgr_rte->claim_cb(pkt, pkt_mgr_rte->claim_arg);
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -24,16 +24,6 @@ const struct route_ctx *packet_get_route_ctx(const struct packet *pkt)
|
||||
return &pkt->meta.route_ctx;
|
||||
}
|
||||
|
||||
void packet_set_origin(struct packet *pkt, struct packet_origin *origin)
|
||||
{
|
||||
pkt->origin = *origin;
|
||||
}
|
||||
|
||||
struct packet_origin *packet_get_origin(struct packet *pkt)
|
||||
{
|
||||
return &pkt->origin;
|
||||
}
|
||||
|
||||
void packet_set_sids(struct packet *pkt, const struct sids *sids)
|
||||
{
|
||||
pkt->meta.sids = *sids;
|
||||
@@ -95,16 +85,6 @@ uint16_t packet_get_link_id(const struct packet *pkt)
|
||||
return pkt->meta.link_id;
|
||||
}
|
||||
|
||||
void packet_set_claim(struct packet *pkt, bool claim)
|
||||
{
|
||||
pkt->meta.is_claim = claim;
|
||||
}
|
||||
|
||||
bool packet_is_claim(const struct packet *pkt)
|
||||
{
|
||||
return pkt->meta.is_claim;
|
||||
}
|
||||
|
||||
void packet_set_direction(struct packet *pkt, enum packet_direction dir)
|
||||
{
|
||||
pkt->meta.direction = dir;
|
||||
@@ -115,26 +95,6 @@ enum packet_direction packet_get_direction(const struct packet *pkt)
|
||||
return pkt->meta.direction;
|
||||
}
|
||||
|
||||
enum packet_type packet_get_type(const struct packet *pkt)
|
||||
{
|
||||
return pkt->type;
|
||||
}
|
||||
|
||||
void packet_set_type(struct packet *pkt, enum packet_type type)
|
||||
{
|
||||
pkt->type = type;
|
||||
}
|
||||
|
||||
void packet_set_action(struct packet *pkt, enum packet_action action)
|
||||
{
|
||||
pkt->meta.action = action;
|
||||
}
|
||||
|
||||
enum packet_action packet_get_action(const struct packet *pkt)
|
||||
{
|
||||
return pkt->meta.action;
|
||||
}
|
||||
|
||||
void packet_set_timeval(struct packet *pkt, const struct timeval *tv)
|
||||
{
|
||||
pkt->meta.tv = *tv;
|
||||
@@ -145,16 +105,6 @@ const struct timeval *packet_get_timeval(const struct packet *pkt)
|
||||
return &pkt->meta.tv;
|
||||
}
|
||||
|
||||
void packet_set_user_data(struct packet *pkt, void *data)
|
||||
{
|
||||
pkt->user_data = data;
|
||||
}
|
||||
|
||||
void *packet_get_user_data(struct packet *pkt)
|
||||
{
|
||||
return pkt->user_data;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* tuple uitls
|
||||
******************************************************************************/
|
||||
@@ -840,42 +790,6 @@ uint64_t packet_ldbc_hash(const struct packet *pkt, enum packet_load_balance_met
|
||||
* other uitls
|
||||
******************************************************************************/
|
||||
|
||||
const char *packet_get_raw_data(const struct packet *pkt)
|
||||
{
|
||||
return pkt->data_ptr;
|
||||
}
|
||||
|
||||
uint16_t packet_get_raw_len(const struct packet *pkt)
|
||||
{
|
||||
return pkt->data_len;
|
||||
}
|
||||
|
||||
const char *packet_get_payload_data(const struct packet *pkt)
|
||||
{
|
||||
if (pkt == NULL || pkt->layers_used == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pkt->layers[pkt->layers_used - 1].pld_len)
|
||||
{
|
||||
return pkt->layers[pkt->layers_used - 1].pld_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t packet_get_payload_len(const struct packet *pkt)
|
||||
{
|
||||
if (pkt == NULL || pkt->layers_used == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return pkt->layers[pkt->layers_used - 1].pld_len;
|
||||
}
|
||||
|
||||
struct packet *packet_new(uint16_t pkt_len)
|
||||
{
|
||||
struct packet *pkt = (struct packet *)calloc(1, sizeof(struct packet) + pkt_len);
|
||||
@@ -1004,6 +918,42 @@ struct packet *packet_pop_frag(struct packet *pkt)
|
||||
return frag;
|
||||
}
|
||||
|
||||
const char *packet_get_raw_data(const struct packet *pkt)
|
||||
{
|
||||
return pkt->data_ptr;
|
||||
}
|
||||
|
||||
uint16_t packet_get_raw_len(const struct packet *pkt)
|
||||
{
|
||||
return pkt->data_len;
|
||||
}
|
||||
|
||||
const char *packet_get_payload_data(const struct packet *pkt)
|
||||
{
|
||||
if (pkt == NULL || pkt->layers_used == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pkt->layers[pkt->layers_used - 1].pld_len)
|
||||
{
|
||||
return pkt->layers[pkt->layers_used - 1].pld_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t packet_get_payload_len(const struct packet *pkt)
|
||||
{
|
||||
if (pkt == NULL || pkt->layers_used == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return pkt->layers[pkt->layers_used - 1].pld_len;
|
||||
}
|
||||
|
||||
void packet_set_exdata(struct packet *pkt, int idx, void *ex_ptr)
|
||||
{
|
||||
struct exdata_runtime *exdata_rt = (struct exdata_runtime *)packet_get_user_data(pkt);
|
||||
@@ -1017,3 +967,53 @@ void *packet_get_exdata(struct packet *pkt, int idx)
|
||||
assert(exdata_rt);
|
||||
return exdata_get(exdata_rt, idx);
|
||||
}
|
||||
|
||||
void packet_set_user_data(struct packet *pkt, void *data)
|
||||
{
|
||||
pkt->user_data = data;
|
||||
}
|
||||
|
||||
void *packet_get_user_data(struct packet *pkt)
|
||||
{
|
||||
return pkt->user_data;
|
||||
}
|
||||
|
||||
void packet_set_origin(struct packet *pkt, struct packet_origin *origin)
|
||||
{
|
||||
pkt->origin = *origin;
|
||||
}
|
||||
|
||||
struct packet_origin *packet_get_origin(struct packet *pkt)
|
||||
{
|
||||
return &pkt->origin;
|
||||
}
|
||||
|
||||
void packet_set_claim(struct packet *pkt, bool claim)
|
||||
{
|
||||
pkt->is_claim = claim;
|
||||
}
|
||||
|
||||
bool packet_is_claim(const struct packet *pkt)
|
||||
{
|
||||
return pkt->is_claim;
|
||||
}
|
||||
|
||||
enum packet_type packet_get_type(const struct packet *pkt)
|
||||
{
|
||||
return pkt->type;
|
||||
}
|
||||
|
||||
void packet_set_type(struct packet *pkt, enum packet_type type)
|
||||
{
|
||||
pkt->type = type;
|
||||
}
|
||||
|
||||
void packet_set_action(struct packet *pkt, enum packet_action action)
|
||||
{
|
||||
pkt->action = action;
|
||||
}
|
||||
|
||||
enum packet_action packet_get_action(const struct packet *pkt)
|
||||
{
|
||||
return pkt->action;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user