Browse code

sctp: direct blacklist support

- blacklist support at the sctp level. If sctp_send_retries are
used, the blacklist will work only for send (using
SCTP_SEND_FAILED notifications). If sctp_send_retries is not
used (default), there are 2 possible blacklist reasons: SEND or
CONNECT (assoc. failed to be opened).

Andrei Pelinescu-Onciul authored on 27/02/2009 21:15:27
Showing 1 changed files
... ...
@@ -22,6 +22,7 @@
22 22
  * History:
23 23
  * --------
24 24
  *  2008-08-07  initial version (andrei)
25
+ *  2009-02-27  blacklist support (andrei)
25 26
  */
26 27
 
27 28
 #ifdef USE_SCTP
... ...
@@ -49,6 +50,9 @@
49 49
 #include "mem/mem.h"
50 50
 #include "ip_addr.h"
51 51
 #include "cfg/cfg_struct.h"
52
+#ifdef USE_DST_BLACKLIST
53
+#include "dst_blacklist.h"
54
+#endif /* USE_DST_BLACKLIST */
52 55
 
53 56
 
54 57
 
... ...
@@ -643,6 +647,16 @@ static int sctp_handle_send_failed(struct socket_info* si,
643 643
 		
644 644
 		ret=sctp_msg_send_raw(&dst, data, data_len, &sinfo);
645 645
 	}
646
+#ifdef USE_DST_BLACKLIST
647
+	 else if (cfg_get(core, core_cfg, use_dst_blacklist) &&
648
+					sctp_options.sctp_send_retries) {
649
+		/* blacklist only if send_retries is on, if off we blacklist
650
+		   from SCTP_ASSOC_CHANGE: SCTP_COMM_LOST/SCTP_CANT_STR_ASSOC
651
+		   which is better (because we can tell connect errors from send
652
+		   errors and we blacklist a failed dst only once) */
653
+		dst_blacklist_su(BLST_ERR_SEND, PROTO_SCTP, su, 0);
654
+	}
655
+#endif /* USE_DST_BLACKLIST */
646 656
 	
647 657
 	return (ret>0)?0:ret;
648 658
 }
... ...
@@ -665,7 +679,7 @@ static int sctp_handle_notification(struct socket_info* si,
665 665
 						text " too short (%d bytes instead of %d bytes)\n", \
666 666
 						su2a((from_su), sizeof(*(from_su))), \
667 667
 						(bind_addr)->name.len, (bind_addr)->name.s, \
668
-						(bind_addr)->port_no, (length), (val)); \
668
+						(bind_addr)->port_no, (int)(length), (int)(val)); \
669 669
 			goto error; \
670 670
 		}
671 671
 
... ...
@@ -735,6 +749,21 @@ static int sctp_handle_notification(struct socket_info* si,
735 735
 					snp->sn_assoc_change.sac_outbound_streams,
736 736
 					snp->sn_assoc_change.sac_inbound_streams
737 737
 					);
738
+#ifdef USE_DST_BLACKLIST
739
+			/* blacklist only if send_retries is turned off (if on we don't 
740
+			   know here if we did retry or we are at the first error) */
741
+			if (cfg_get(core, core_cfg, use_dst_blacklist) &&
742
+					(sctp_options.sctp_send_retries==0)){
743
+				switch(snp->sn_assoc_change.sac_state) {
744
+					case SCTP_CANT_STR_ASSOC:
745
+						dst_blacklist_su(BLST_ERR_CONNECT, PROTO_SCTP, su, 0);
746
+						break;
747
+					case SCTP_COMM_LOST:
748
+						dst_blacklist_su(BLST_ERR_SEND, PROTO_SCTP, su, 0);
749
+						break;
750
+				}
751
+			}
752
+#endif /* USE_DST_BLACKLIST */
738 753
 			break;
739 754
 #ifdef SCTP_ADAPTION_INDICATION
740 755
 		case SCTP_ADAPTION_INDICATION: