Diff for /fwsync/driver/fwsync_workers.c between versions 1.4 and 1.8

version 1.4, 2022/07/11 15:59:42 version 1.8, 2022/08/04 00:24:39
Line 5 Line 5
 #include "fwsync.h"  #include "fwsync.h"
   
   
   static int
   fwsync_add_state_4(struct ipfw_flow_id *fid, u_int ruleid, u_short rulenum)
   {
           struct ip_fw *rule = NULL;
           struct ip_fw_args args;
           struct ipfw_dyn_info info;
           ipfw_insn cmd;
   
           DTRACE();
   
           memset(&cmd, 0, sizeof cmd);
           cmd.opcode = O_KEEP_STATE;
           memset(&info, 0, sizeof info);
           memset(&args, 0, sizeof args);
           memcpy(&args.f_id, fid, sizeof args.f_id);
   
           rule = ipfw_dyn_lookup_state(&args, NULL, 0, &cmd, &info);
           printf("rule=%p\n", rule);
           return 0;
   //      return ipfw_dyn_install_sync_state(fid, rule, ruleid, rulenum);
   }
   
   static int
   fwsync_add_state_6(struct ipfw_flow_id *fid, u_int ruleid, u_short rulenum)
   {
           DTRACE();
   
           return 0;
   }
   
   int
   fwsync_add_state(const struct fws_proto *pkt)
   {
           struct ipfw_flow_id fid;
   
           DTRACE();
   
           memset(&fid, 0, sizeof fid);
           fid.fib = pkt->fws_fib;
           fid.proto = pkt->fws_proto;
           fid.addr_type = pkt->fws_addrtype;
           fid.src_port = pkt->fws_sport;
           fid.dst_port = pkt->fws_dport;
           switch (pkt->fws_addrtype) {
                   case 4:
                           fid.src_ip = pkt->fws_saddr.s_addr;
                           fid.dst_ip = pkt->fws_daddr.s_addr;
                           break;
                   case 6:
                           memcpy(&fid.src_ip6, &pkt->fws_saddr6, sizeof fid.src_ip6);
                           memcpy(&fid.dst_ip6, &pkt->fws_daddr6, sizeof fid.dst_ip6);
                           fid.flow_id6 = pkt->fws_scopeid;
                           break;
                   default:
                           return EINVAL;
           }
   
           if (pkt->fws_addrtype == 4)
                   fwsync_add_state_4(&fid, pkt->fws_ruleid, pkt->fws_rulenum);
           else if (pkt->fws_addrtype == 6)
                   fwsync_add_state_6(&fid, pkt->fws_ruleid, pkt->fws_rulenum);
           else
                   return EINVAL;
   
           return 0;
   }
   
   int
   fwsync_add_alias(const struct fws_proto *pkt)
   {
           DTRACE();
   
           return 0;
   }
   
   
 void  void
 fwsync_sndpkt_handler(void *context, int pending)  fwsync_sndpkt_handler(void *context, int pending)
 {  {
Line 75  out: Line 151  out:
 }  }
   
 int  int
fwsync_state_handler(const void *arg)fwsync_state_handler(const void *arg, const void *extdata)
 {  {
         const struct ipfw_flow_id *pkt = arg;          const struct ipfw_flow_id *pkt = arg;
           const struct ipfw_dyn_hook_extdata *edata = extdata;
         struct fws_proto *spkt;          struct fws_proto *spkt;
         struct fws_sndpkt *p;          struct fws_sndpkt *p;
   
Line 88  fwsync_state_handler(const void *arg) Line 165  fwsync_state_handler(const void *arg)
   
         mtx_lock(&fws_mtx_c);          mtx_lock(&fws_mtx_c);
   
        p = malloc(sizeof(struct fws_proto), M_FWSYNC, M_NOWAIT | M_ZERO);        p = malloc(sizeof(struct fws_sndpkt), M_FWSYNC, M_NOWAIT | M_ZERO);
         if (!p) {          if (!p) {
                 mtx_unlock(&fws_mtx_c);                  mtx_unlock(&fws_mtx_c);
                 return 0;                  return 0;
Line 97  fwsync_state_handler(const void *arg) Line 174  fwsync_state_handler(const void *arg)
   
         spkt->fws_version = FWS_PKTVER_STATE;          spkt->fws_version = FWS_PKTVER_STATE;
         spkt->fws_fib = pkt->fib;          spkt->fws_fib = pkt->fib;
           spkt->fws_ruleid = edata->ruleid;
           spkt->fws_rulenum = edata->rulenum;
         spkt->fws_proto = pkt->proto;          spkt->fws_proto = pkt->proto;
         spkt->fws_addrtype = pkt->addr_type;          spkt->fws_addrtype = pkt->addr_type;
         spkt->fws_sport = pkt->src_port;          spkt->fws_sport = pkt->src_port;
Line 128  fwsync_state_handler(const void *arg) Line 207  fwsync_state_handler(const void *arg)
 }  }
   
 int  int
fwsync_alias_handler(const void *arg)fwsync_alias_handler(const void *arg, const void *extdata)
 {  {
         const struct alias_link *lnk = arg;          const struct alias_link *lnk = arg;
         struct fws_proto *spkt;          struct fws_proto *spkt;
Line 141  fwsync_alias_handler(const void *arg) Line 220  fwsync_alias_handler(const void *arg)
   
         mtx_lock(&fws_mtx_c);          mtx_lock(&fws_mtx_c);
   
        p = malloc(sizeof(struct fws_proto), M_FWSYNC, M_NOWAIT | M_ZERO);        p = malloc(sizeof(struct fws_sndpkt), M_FWSYNC, M_NOWAIT | M_ZERO);
         if (!p) {          if (!p) {
                 mtx_unlock(&fws_mtx_c);                  mtx_unlock(&fws_mtx_c);
                 return 0;                  return 0;

Removed from v.1.4  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>