Hello All,<br> I have attached the code snippet for extending tproxy to support sctp functionality.<br><br> For the socket lookup I use:<br> <br>struct sock *nf_tproxy_get_sock_sctp4(const struct sk_buff *skb){<br>
<br> struct sctp_association *asoc;<br> union sctp_addr *saddr , *daddr;<br> struct sctp_transport **transport;<br> struct sctphdr *sh;<br> struct sock *sk;<br><br> void *temp;<br> void *temp1;<br><br> memset(saddr,0,sizeof(saddr));<br>
memset(daddr,0,sizeof(daddr));<br><br> saddr->v4.sin_family = AF_INET;<br> daddr->v4.sin_family = AF_INET;<br><br> sh = sctp_hdr(skb);<br><br> temp=&ip_hdr(skb)->saddr;<br> temp1=&ip_hdr(skb)->daddr;<br>
<br> memcpy(&saddr->v4.sin_addr.s_addr,temp, sizeof(struct in_addr));<br> memcpy(&daddr->v4.sin_addr.s_addr,temp1, sizeof(struct in_addr));<br><br><br> asoc = __sctp_get_association(saddr, daddr, transport);<br>
if (!asoc)<br> sk=NULL;<br> sk = asoc-><a href="http://base.sk">base.sk</a>;<br><br>return sk;<br>}<br><br>This function I plan to invoke from both xt_TPROXY.c and xt_socket.c for sctp instead of the existing function for tcp and udp.<br>
<br>if(iph->protocol == IPPROTO_TCP || iph->protocol == IPPROTO_UDP){<br> sk = nf_tproxy_get_sock_v4(dev_net(skb->dev), iph->protocol,<br> iph->saddr, tgi->laddr ? tgi->laddr : iph->daddr,<br>
hp->source, tgi->lport ? tgi->lport : hp->dest,<br> par->in, true);<br> }<br><br> else<br> if(iph->protocol == IPPROTO_SCTP){<br>
sk = nf_tproxy_get_sock_sctp4(skb);<br> }<br><br>Have I missed out any condition during the socket lookup ?<br>What about the icmp support?Can I just reuse the existing functionality by adding sctp to the list of protocols?<br>
<br>Thanks and Regards,<br> Maria<br><br>