Skip to content

Commit

Permalink
Merge "Manipulating the TTL of the Packet" into R3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 31, 2016
2 parents 47d62dc + 42bd7dd commit 24cf44f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
21 changes: 21 additions & 0 deletions dp-core/vr_flow.c
Expand Up @@ -222,6 +222,7 @@ __vr_flow_reset_entry(struct vrouter *router, struct vr_flow_entry *fe)
fe->fe_flags &=
(VR_FLOW_FLAG_ACTIVE | VR_FLOW_FLAG_EVICTED |
VR_FLOW_FLAG_NEW_FLOW | VR_FLOW_FLAG_DELETE_MARKED);
fe->fe_ttl = 0;

return;
}
Expand Down Expand Up @@ -778,6 +779,8 @@ vr_flow_action(struct vrouter *router, struct vr_flow_entry *fe,
struct vr_forwarding_md *fmd)
{
int valid_src;
unsigned int ip_inc_diff_cksum = 0;
struct vr_ip *ip;

flow_result_t result;

Expand Down Expand Up @@ -861,6 +864,22 @@ vr_flow_action(struct vrouter *router, struct vr_flow_entry *fe,
break;
}

if (result == FLOW_FORWARD) {
if (pkt->vp_type == VP_TYPE_IP) {
ip = (struct vr_ip *)pkt_network_header(pkt);
if (ip) {
if (fe->fe_ttl && (fe->fe_ttl != ip->ip_ttl)) {
vr_incremental_diff(ip->ip_ttl, fe->fe_ttl, &ip_inc_diff_cksum);
ip->ip_ttl = fe->fe_ttl;

if (ip_inc_diff_cksum)
vr_ip_incremental_csum(ip, ip_inc_diff_cksum);
}
}
}
}


if (fe->fe_tcp_flags & VR_FLOW_TCP_DEAD)
vr_flow_mark_evict(router, fe, index);

Expand Down Expand Up @@ -1956,6 +1975,8 @@ vr_flow_set(struct vrouter *router, vr_flow_req *req)
fe->fe_action = req->fr_action;
}

fe->fe_ttl = req->fr_ttl;

if (fe->fe_action == VR_FLOW_ACTION_DROP)
fe->fe_drop_reason = (uint8_t)req->fr_drop_reason;

Expand Down
3 changes: 2 additions & 1 deletion dp-core/vr_proto_ip.c
Expand Up @@ -97,7 +97,8 @@ vr_ip_update_csum(struct vr_packet *pkt, unsigned int ip_inc, unsigned int inc)
unsigned short *csump;

ip = (struct vr_ip *)pkt_network_header(pkt);
ip->ip_csum = vr_ip_csum(ip);
if (ip_inc)
vr_ip_incremental_csum(ip, ip_inc);

if (ip->ip_proto == VR_IP_PROTO_TCP) {
tcp = (struct vr_tcp *)((unsigned char *)ip + ip->ip_hl * 4);
Expand Down
4 changes: 2 additions & 2 deletions include/vr_flow.h
Expand Up @@ -301,7 +301,7 @@ struct vr_flow_queue {

struct vr_dummy_flow_entry {
vr_hentry_t fe_hentry;
uint8_t fe_pack_hentry;
uint8_t fe_ttl;
int16_t fe_qos_id;
struct vr_flow fe_key;
uint8_t fe_gen_id;
Expand Down Expand Up @@ -329,7 +329,7 @@ struct vr_dummy_flow_entry {
/* do not change. any field positions as it might lead to incompatibility */
struct vr_flow_entry {
vr_hentry_t fe_hentry;
uint8_t fe_pack_hentry;
uint8_t fe_ttl;
int16_t fe_qos_id;
struct vr_flow fe_key;
uint8_t fe_gen_id;
Expand Down
8 changes: 7 additions & 1 deletion include/vr_packet.h
Expand Up @@ -412,7 +412,12 @@ vr_ip_incremental_csum(struct vr_ip *ip, unsigned int diff)
{
unsigned int csum;

diff &= 0xffff;
diff = (diff >> 16) + (diff & 0xffff);
if (diff >> 16) {
diff &= 0xffff;
diff += 1;
}

csum = ~(ip->ip_csum) & 0xffff;
csum += diff;
csum = (csum >> 16) + (csum & 0xffff);
Expand Down Expand Up @@ -707,6 +712,7 @@ vr_ip_transport_header_valid(struct vr_ip *iph)
}



#define VR_TCP_FLAG_FIN 0x0001
#define VR_TCP_FLAG_SYN 0x0002
#define VR_TCP_FLAG_RST 0x0004
Expand Down
1 change: 1 addition & 0 deletions sandesh/vr.sandesh
Expand Up @@ -191,6 +191,7 @@ buffer sandesh vr_flow_req {
36: i32 fr_oflow_entries;
37: byte fr_gen_id;
38: i16 fr_qos_id;
39: byte fr_ttl;
}

buffer sandesh vr_vrf_assign_req {
Expand Down
1 change: 1 addition & 0 deletions utils/flow.c
Expand Up @@ -1401,6 +1401,7 @@ flow_dump_table(struct flow_table *ft)
printf(", %d, ", fe->fe_sec_mirror_id);
}
printf(" SPort %d", fe->fe_udp_src_port);
printf(" TTL %d", fe->fe_ttl);
printf(")");
}

Expand Down

0 comments on commit 24cf44f

Please sign in to comment.