OSDN Git Service

Fix pfilter module.
[ultramonkey-l7/ultramonkey-l7-v2.git] / module / protocol / protomod_pfilter.c
index 1182f4b..c285193 100644 (file)
@@ -93,7 +93,7 @@ static struct l7vs_protomod pfilter_protomod = {
        NULL,           /* handle */
        "pfilter",          /* modname */
        0,              /* refcnt */
-       0,              /* fast schedule */
+       1,              /* fast schedule */
        create,         /* create function */
        compare,        /* compare function */
        select_dest,    /* select_dest function */
@@ -455,7 +455,6 @@ select_dest(struct l7vs_service *srv, struct l7vs_conn *conn,
        struct l7vs_pfilter_service *pfilter_service;
        int ret;
        int return_value = 0;
-    std::string packet_data;
 
        /*-------- DEBUG LOG --------*/
        if (pfilter_protomod.get_log_level != NULL &&
@@ -594,7 +593,7 @@ analyze_cldata(struct l7vs_service *srv, struct l7vs_conn *conn,
                else {
                        strncpy(len_str, "NULL", DEBUG_STR_LEN);
                }
-               PUT_LOG_DEBUG(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,296,
+               PUT_LOG_DEBUG(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,334,
                    "in_function: int analyze_cldata(struct l7vs_service* srv, struct l7vs_conn* conn, "
                    "char* request, size_t* len):srv=&(%s), conn=&(%s), "
                    "request=\"%s\", len=&(%s))",
@@ -604,22 +603,22 @@ analyze_cldata(struct l7vs_service *srv, struct l7vs_conn *conn,
 
        /* check null */
        if (srv == NULL) {
-               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,253, "Arg(srv) is NULL pointer.");
+               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,329, "Arg(srv) is NULL pointer.");
                return_value = -1;
                goto analyze_cldata_out;
        }
        if (srv->pm == NULL) {
-               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,254, "Arg(srv->pm) is NULL pointer.");
+               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,330, "Arg(srv->pm) is NULL pointer.");
                return_value = -1;
                goto analyze_cldata_out;
        }
        if (request == NULL) {
-               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,255, "Arg(request) is NULL pointer.");
+               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,331, "Arg(request) is NULL pointer.");
                return_value = -1;
                goto analyze_cldata_out;
        }
        if (len == NULL) {
-               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,256, "Arg(len) is NULL pointer.");
+               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,332, "Arg(len) is NULL pointer.");
                return_value = -1;
                goto analyze_cldata_out;
        }
@@ -632,13 +631,13 @@ analyze_cldata(struct l7vs_service *srv, struct l7vs_conn *conn,
            LOG_LV_DEBUG == pfilter_protomod.get_log_level(LOG_CAT_L7VSD_PROTOCOL)) {
                char pfilter_str[DEBUG_STR_LEN] = {0};
                l7vs_pfilter_service_c_str(pfilter_str, pfilter_service);
-               PUT_LOG_DEBUG(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,297, "pointer assign: pfilter_service=&(%s)",
+               PUT_LOG_DEBUG(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,335, "pointer assign: pfilter_service=&(%s)",
                    pfilter_str);
        }
        /*------ DEBUG LOG END ------*/
 
        if (pfilter_service == NULL) {
-               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,259, "Could not find such service handle's pfilter service.");
+               PUT_LOG_ERROR(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,333, "Could not find such service handle's pfilter service.");
                return_value = -1;
                goto analyze_cldata_out;
        }
@@ -663,7 +662,9 @@ analyze_cldata(struct l7vs_service *srv, struct l7vs_conn *conn,
 #else
        if ( boost::regex_search(packet_data, pfilter_service->regex) ) {
 #endif
-               return_value = -1;
+               PUT_LOG_INFO(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL, 20,
+                   "Connection reset by packet filter module");
+               conn->ciom->status = iomux_conn_disconnected;
                goto analyze_cldata_out;
        }
 
@@ -671,7 +672,7 @@ analyze_cldata_out:
        /*-------- DEBUG LOG --------*/
        if (pfilter_protomod.get_log_level != NULL &&
            LOG_LV_DEBUG == pfilter_protomod.get_log_level(LOG_CAT_L7VSD_PROTOCOL)) {
-               PUT_LOG_DEBUG(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,298,
+               PUT_LOG_DEBUG(pfilter_protomod, LOG_CAT_L7VSD_PROTOCOL,336,
                    "out_function: int analyze_cldata(struct l7vs_service* srv, struct l7vs_conn* conn, "
                    "char* request, size_t* len):return_value=%d",
                    return_value);