I don't know about iRule error message.

We make simple irule for 2 byte udp payload based LB.

when CLIENT_DATA {
set index1 [UDP::payload 2]
set div1 [expr (($index1)%2)]
log local0. "index_6001: $index1"
log local0. "div_6001: $div1"
if {$div1 == 0} {
pool pool_s1_6001
}
if {$div1 == 1} {
pool pool_s2_6001
}
}

But we has problem.

We’ve got errlr log when $index’s result 08 or 09.

But 18, 19, 28, 29, 00, etc.. numbers are doesn’t have problem.

Anyone know about this?

Oct 10 11:10:20 tmm tmm[728]: 01220001:3: TCL error: Rule rule_udp_6001_lb  - expected integer but got "09" (looks like invalid octal number)     while executing "expr (($index1)%2)"
Oct 10 11:10:20 tmm tmm[728]: 01220001:3: TCL error: Rule rule_udp_6001_lb  - expected integer but got "09" (looks like invalid octal number)     while executing "expr (($index1)%2)"

From the format man page:

i

Convert integer to signed decimal string; the integer may either be in decimal, in octal (with a leading 0) or in hexadecimal (with a leading 0x).Looks like the leading 0 indicates an octal value, and 8 & 9 are not legal octal digits.

I couldn’t figure out a way to get format to solve this problem, but here’s something that should work around the issue until a better solution is found:

when CLIENT_DATA {
  if {[UDP::payload 2] < 10 }{
    set index1 [substr [UDP::payload 2] 1 1]
  } else {
    set index1 [UDP::payload 2]
  }
  set div1 [expr {$index1%2}] 
  log local0. "index_6001: $index1"
  log local0. "div_6001: $div1"
  if {$div1 == 0} {
    pool pool_s1_6001
  } else {
    pool pool_s2_6001
  }
}

HTH, and please post back (anybody!) if you find a cleaner solution.

/deb

(oops, had to clean that blockquote up a bit, see above for corrections)

Wow!. It’ works! Thanks a lot of your answer.

But we have another problem

I changed a little. But I got another error log.

That was “Address in use” error. But iRule is working well when occur error log.

Oct 11 12:15:18 tmm tmm[731]: Rule rule_udp_6001_lb_new : index_6001: 9
Oct 11 12:15:18 tmm tmm[731]: Rule rule_udp_6001_lb_new : div_6001: 1
Oct 11 12:15:18 tmm tmm[731]: Rule rule_udp_6001_lb_new : select pool S2_6001
Oct 11 12:15:18 tmm tmm[731]: 01220001:3: TCL error: Rule rule_udp_6001_lb_new  - Address in use (line 11)     invoked from within "pool pool_s2_6001"
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : index_6001: 8
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : div_6001: 0
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : select pool S1_6001
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : index_6001: 8
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : div_6001: 0
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : select pool S1_6001
Oct 11 12:18:07 tmm tmm[731]: 01220001:3: TCL error: Rule rule_udp_6001_lb_new  - Address in use (line 11)     invoked from within "pool pool_s1_6001"
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : index_6001: 8
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : div_6001: 0
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : select pool S1_6001
Oct 11 12:18:07 tmm tmm[731]: 01220001:3: TCL error: Rule rule_udp_6001_lb_new  - Address in use (line 14)     invoked from within "pool pool_s1_6001"
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : index_6001: 8
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : div_6001: 0
Oct 11 12:18:07 tmm tmm[731]: Rule rule_udp_6001_lb_new : select pool S1_6001
Oct 11 12:18:07 tmm tmm[731]: 01220001:3: TCL error: Rule rule_udp_6001_lb_new  - Address in use (line 14)     invoked from within "pool pool_s1_6001"
when CLIENT_DATA {
  if {[UDP::payload 2] < 10 }{
    set index1 [substr [UDP::payload 2] 1 1]
  } else {
    set index1 [UDP::payload 2]
  }
  set div1 [expr {$index1%2}] 
  log local0. "index_6001: $index1"
  log local0. "div_6001: $div1"
  if {$div1 == 1} {
    log local0. "select pool S2_6001"
    pool pool_s2_6001
  } else {
    log local0. "select pool S1_6001"
    pool pool_s1_6001
  }
}