Skip to content

Commit

Permalink
If we are receiving/sending from/to an interface with advertised addr…
Browse files Browse the repository at this point in the history
…ess, replicate to HEP using the advertised address
  • Loading branch information
vladpaiu committed Dec 11, 2023
1 parent 1ea1852 commit a13e034
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modules/tracer/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ static int sip_trace(struct sip_msg *msg, trace_info_p info, int leg_flag)
}

set_sock_columns( db_vals[4], db_vals[5], db_vals[6], fromip_buff,
&msg->rcv.src_ip, msg->rcv.src_port, msg->rcv.proto);
msg->rcv.bind_address->adv_sock_str.len?(struct ip_addr *)&msg->rcv.bind_address->adv_address:&msg->rcv.dst_ip, msg->rcv.bind_address->adv_sock_str.len?msg->rcv.bind_address->adv_port:msg->rcv.dst_port, msg->rcv.proto);

This comment has been minimized.

Copy link
@liviuchircu

liviuchircu Jan 8, 2024

Member

Hey, @vladpaiu! Are we sure this is correct? Not only do the semantics change from src_ip to dst_ip without being hinted in the patch notes, but look 2 lines below and the dst_ip and dst_port are both being recorded again! So this has to be some kind of copy/paste error, right?

Context: see the replicate to HEP using the advertised address thread on Users


set_sock_columns( db_vals[7], db_vals[8], db_vals[9], toip_buff,
&msg->rcv.dst_ip, msg->rcv.dst_port, msg->rcv.proto);
Expand Down Expand Up @@ -2238,7 +2238,7 @@ static int sip_trace_instance(struct sip_msg* msg,
&msg->rcv.src_ip, msg->rcv.src_port, msg->rcv.proto);

set_sock_columns( db_vals[7], db_vals[8], db_vals[9], toip_buff,
&msg->rcv.dst_ip, msg->rcv.dst_port, msg->rcv.proto);
msg->rcv.bind_address->adv_sock_str.len?(struct ip_addr *)&msg->rcv.bind_address->adv_address:&msg->rcv.dst_ip, msg->rcv.bind_address->adv_sock_str.len?msg->rcv.bind_address->adv_port:msg->rcv.dst_port, msg->rcv.proto);

db_vals[10].val.time_val = time(NULL);

Expand Down Expand Up @@ -2367,7 +2367,7 @@ static void trace_slreply_out(struct sip_msg* req, str *buffer,int rpl_code,
set_columns_to_trace_local_ip( db_vals[4], db_vals[5], db_vals[6]);
} else {
set_sock_columns( db_vals[4], db_vals[5], db_vals[6], fromip_buff,
&req->rcv.dst_ip, req->rcv.dst_port, req->rcv.proto);
req->rcv.bind_address->adv_sock_str.len?(struct ip_addr *)&req->rcv.bind_address->adv_address:&req->rcv.dst_ip, req->rcv.bind_address->adv_sock_str.len?req->rcv.bind_address->adv_port:req->rcv.dst_port, req->rcv.proto);
}

char * str_code = int2str(rpl_code, &len);
Expand Down Expand Up @@ -2514,12 +2514,12 @@ static void trace_msg_out(struct sip_msg* msg, str *sbuf,
if(send_sock==0 || send_sock->sock_str.s==0)
{
set_sock_columns( db_vals[4], db_vals[5], db_vals[6], fromip_buff,
&msg->rcv.dst_ip, msg->rcv.dst_port, msg->rcv.proto);
msg->rcv.bind_address->adv_sock_str.len?(struct ip_addr *)&msg->rcv.bind_address->adv_address:&msg->rcv.dst_ip, msg->rcv.bind_address->adv_sock_str.len?msg->rcv.bind_address->adv_port:msg->rcv.dst_port, msg->rcv.proto);
} else {
char *nbuff = proto2str(send_sock->proto,fromip_buff);
db_vals[4].val.str_val.s = fromip_buff;
db_vals[4].val.str_val.len = nbuff - fromip_buff;
db_vals[5].val.str_val = send_sock->address_str;
db_vals[5].val.str_val = send_sock->adv_sock_str.len?send_sock->adv_name_str:send_sock->address_str;
db_vals[6].val.int_val = send_sock->last_real_ports->local?
send_sock->last_real_ports->local:send_sock->port_no;
}
Expand Down Expand Up @@ -2644,7 +2644,7 @@ static void trace_onreply_in(struct cell* t, int type, struct tmcb_params *ps,
}
else {
set_sock_columns( db_vals[7], db_vals[8], db_vals[9], toip_buff,
&msg->rcv.dst_ip, msg->rcv.dst_port, msg->rcv.proto);
msg->rcv.bind_address->adv_sock_str.len?(struct ip_addr *)&msg->rcv.bind_address->adv_address:&msg->rcv.dst_ip, msg->rcv.bind_address->adv_sock_str.len?msg->rcv.bind_address->adv_port:msg->rcv.dst_port, msg->rcv.proto);
}

db_vals[10].val.time_val = time(NULL);
Expand Down Expand Up @@ -2802,12 +2802,12 @@ static void trace_onreply_out(struct cell* t, int type, struct tmcb_params *ps,
if(dst==NULL || dst->send_sock==0 || dst->send_sock->sock_str.s==0)
{
set_sock_columns( db_vals[4], db_vals[5], db_vals[6], fromip_buff,
&msg->rcv.dst_ip, msg->rcv.dst_port, msg->rcv.proto);
msg->rcv.bind_address->adv_sock_str.len?(struct ip_addr *)&msg->rcv.bind_address->adv_address:&msg->rcv.dst_ip, msg->rcv.bind_address->adv_sock_str.len?msg->rcv.bind_address->adv_port:msg->rcv.dst_port, msg->rcv.proto);
} else {
char *nbuff = proto2str(dst->send_sock->proto,fromip_buff);
db_vals[4].val.str_val.s = fromip_buff;
db_vals[4].val.str_val.len = nbuff - fromip_buff;
db_vals[5].val.str_val = dst->send_sock->address_str;
db_vals[5].val.str_val = dst->send_sock->adv_sock_str.len?dst->send_sock->adv_name_str:dst->send_sock->address_str;
db_vals[6].val.int_val = dst->send_sock->last_real_ports->local?
dst->send_sock->last_real_ports->local:dst->send_sock->port_no;
}
Expand Down

2 comments on commit a13e034

@bogdan-iancu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the global advertising (core param) or per msg advertising ? shouldn't we take this into consideration too, for consistency reasons ?

@vladpaiu
Copy link
Member Author

@vladpaiu vladpaiu commented on a13e034 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

advertised address core param or per message advertising only affect the contents of the SIP message itself, but they don't affect any IP layer behavior.

the per send socket advertised is the one that actually translated to real-life IP address mapping ( ie. running in AWS with socket=wss:AWS_PRIVATE_IP:443 as AWS_PUBLIC_IP ) - the patch only changes the IP addresses ( incoming & outgoing ) when they're replicated to homer, the content of the SIP message remains the same.

Please sign in to comment.