iptables_test.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. // Copyright 2015 CoreOS, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package iptables
  15. import (
  16. "crypto/rand"
  17. "fmt"
  18. "math/big"
  19. "net"
  20. "os"
  21. "reflect"
  22. "testing"
  23. )
  24. func TestProto(t *testing.T) {
  25. ipt, err := New()
  26. if err != nil {
  27. t.Fatalf("New failed: %v", err)
  28. }
  29. if ipt.Proto() != ProtocolIPv4 {
  30. t.Fatalf("Expected default protocol IPv4, got %v", ipt.Proto())
  31. }
  32. ip4t, err := NewWithProtocol(ProtocolIPv4)
  33. if err != nil {
  34. t.Fatalf("NewWithProtocol(ProtocolIPv4) failed: %v", err)
  35. }
  36. if ip4t.Proto() != ProtocolIPv4 {
  37. t.Fatalf("Expected protocol IPv4, got %v", ip4t.Proto())
  38. }
  39. ip6t, err := NewWithProtocol(ProtocolIPv6)
  40. if err != nil {
  41. t.Fatalf("NewWithProtocol(ProtocolIPv6) failed: %v", err)
  42. }
  43. if ip6t.Proto() != ProtocolIPv6 {
  44. t.Fatalf("Expected protocol IPv6, got %v", ip6t.Proto())
  45. }
  46. }
  47. func randChain(t *testing.T) string {
  48. n, err := rand.Int(rand.Reader, big.NewInt(1000000))
  49. if err != nil {
  50. t.Fatalf("Failed to generate random chain name: %v", err)
  51. }
  52. return "TEST-" + n.String()
  53. }
  54. func contains(list []string, value string) bool {
  55. for _, val := range list {
  56. if val == value {
  57. return true
  58. }
  59. }
  60. return false
  61. }
  62. // mustTestableIptables returns a list of ip(6)tables handles with various
  63. // features enabled & disabled, to test compatibility.
  64. // We used to test noWait as well, but that was removed as of iptables v1.6.0
  65. func mustTestableIptables() []*IPTables {
  66. ipt, err := New()
  67. if err != nil {
  68. panic(fmt.Sprintf("New failed: %v", err))
  69. }
  70. ip6t, err := NewWithProtocol(ProtocolIPv6)
  71. if err != nil {
  72. panic(fmt.Sprintf("NewWithProtocol(ProtocolIPv6) failed: %v", err))
  73. }
  74. ipts := []*IPTables{ipt, ip6t}
  75. // ensure we check one variant without built-in checking
  76. if ipt.hasCheck {
  77. i := *ipt
  78. i.hasCheck = false
  79. ipts = append(ipts, &i)
  80. i6 := *ip6t
  81. i6.hasCheck = false
  82. ipts = append(ipts, &i6)
  83. } else {
  84. panic("iptables on this machine is too old -- missing -C")
  85. }
  86. return ipts
  87. }
  88. func TestChain(t *testing.T) {
  89. for i, ipt := range mustTestableIptables() {
  90. t.Run(fmt.Sprint(i), func(t *testing.T) {
  91. runChainTests(t, ipt)
  92. })
  93. }
  94. }
  95. func runChainTests(t *testing.T, ipt *IPTables) {
  96. t.Logf("testing %s (hasWait=%t, hasCheck=%t)", ipt.path, ipt.hasWait, ipt.hasCheck)
  97. chain := randChain(t)
  98. // Saving the list of chains before executing tests
  99. originaListChain, err := ipt.ListChains("filter")
  100. if err != nil {
  101. t.Fatalf("ListChains of Initial failed: %v", err)
  102. }
  103. // chain shouldn't exist, this will create new
  104. err = ipt.ClearChain("filter", chain)
  105. if err != nil {
  106. t.Fatalf("ClearChain (of missing) failed: %v", err)
  107. }
  108. // chain should be in listChain
  109. listChain, err := ipt.ListChains("filter")
  110. if err != nil {
  111. t.Fatalf("ListChains failed: %v", err)
  112. }
  113. if !contains(listChain, chain) {
  114. t.Fatalf("ListChains doesn't contain the new chain %v", chain)
  115. }
  116. // ChainExists should find it, too
  117. exists, err := ipt.ChainExists("filter", chain)
  118. if err != nil {
  119. t.Fatalf("ChainExists for existing chain failed: %v", err)
  120. } else if !exists {
  121. t.Fatalf("ChainExists doesn't find existing chain")
  122. }
  123. // chain now exists
  124. err = ipt.ClearChain("filter", chain)
  125. if err != nil {
  126. t.Fatalf("ClearChain (of empty) failed: %v", err)
  127. }
  128. // put a simple rule in
  129. err = ipt.Append("filter", chain, "-s", "0/0", "-j", "ACCEPT")
  130. if err != nil {
  131. t.Fatalf("Append failed: %v", err)
  132. }
  133. // can't delete non-empty chain
  134. err = ipt.DeleteChain("filter", chain)
  135. if err == nil {
  136. t.Fatalf("DeleteChain of non-empty chain did not fail")
  137. }
  138. e, ok := err.(*Error)
  139. if ok && e.IsNotExist() {
  140. t.Fatal("DeleteChain of non-empty chain returned IsNotExist")
  141. }
  142. err = ipt.ClearChain("filter", chain)
  143. if err != nil {
  144. t.Fatalf("ClearChain (of non-empty) failed: %v", err)
  145. }
  146. // rename the chain
  147. newChain := randChain(t)
  148. err = ipt.RenameChain("filter", chain, newChain)
  149. if err != nil {
  150. t.Fatalf("RenameChain failed: %v", err)
  151. }
  152. // chain empty, should be ok
  153. err = ipt.DeleteChain("filter", newChain)
  154. if err != nil {
  155. t.Fatalf("DeleteChain of empty chain failed: %v", err)
  156. }
  157. // check that chain is fully gone and that state similar to initial one
  158. listChain, err = ipt.ListChains("filter")
  159. if err != nil {
  160. t.Fatalf("ListChains failed: %v", err)
  161. }
  162. if !reflect.DeepEqual(originaListChain, listChain) {
  163. t.Fatalf("ListChains mismatch: \ngot %#v \nneed %#v", originaListChain, listChain)
  164. }
  165. // ChainExists must not find it anymore
  166. exists, err = ipt.ChainExists("filter", chain)
  167. if err != nil {
  168. t.Fatalf("ChainExists for non-existing chain failed: %v", err)
  169. } else if exists {
  170. t.Fatalf("ChainExists finds non-existing chain")
  171. }
  172. // test ClearAndDelete
  173. err = ipt.NewChain("filter", chain)
  174. if err != nil {
  175. t.Fatalf("NewChain failed: %v", err)
  176. }
  177. err = ipt.Append("filter", chain, "-j", "ACCEPT")
  178. if err != nil {
  179. t.Fatalf("Append failed: %v", err)
  180. }
  181. err = ipt.ClearAndDeleteChain("filter", chain)
  182. if err != nil {
  183. t.Fatalf("ClearAndDelete failed: %v", err)
  184. }
  185. exists, err = ipt.ChainExists("filter", chain)
  186. if err != nil {
  187. t.Fatalf("ChainExists failed: %v", err)
  188. }
  189. if exists {
  190. t.Fatalf("ClearAndDelete didn't delete the chain")
  191. }
  192. err = ipt.ClearAndDeleteChain("filter", chain)
  193. if err != nil {
  194. t.Fatalf("ClearAndDelete failed for non-existing chain: %v", err)
  195. }
  196. }
  197. func TestRules(t *testing.T) {
  198. for i, ipt := range mustTestableIptables() {
  199. t.Run(fmt.Sprint(i), func(t *testing.T) {
  200. runRulesTests(t, ipt)
  201. })
  202. }
  203. }
  204. func runRulesTests(t *testing.T, ipt *IPTables) {
  205. t.Logf("testing %s (hasWait=%t, hasCheck=%t)", getIptablesCommand(ipt.Proto()), ipt.hasWait, ipt.hasCheck)
  206. var address1, address2, subnet1, subnet2 string
  207. if ipt.Proto() == ProtocolIPv6 {
  208. address1 = "2001:db8::1/128"
  209. address2 = "2001:db8::2/128"
  210. subnet1 = "2001:db8:a::/48"
  211. subnet2 = "2001:db8:b::/48"
  212. } else {
  213. address1 = "203.0.113.1/32"
  214. address2 = "203.0.113.2/32"
  215. subnet1 = "192.0.2.0/24"
  216. subnet2 = "198.51.100.0/24"
  217. }
  218. chain := randChain(t)
  219. // chain shouldn't exist, this will create new
  220. err := ipt.ClearChain("filter", chain)
  221. if err != nil {
  222. t.Fatalf("ClearChain (of missing) failed: %v", err)
  223. }
  224. err = ipt.Append("filter", chain, "-s", subnet1, "-d", address1, "-j", "ACCEPT")
  225. if err != nil {
  226. t.Fatalf("Append failed: %v", err)
  227. }
  228. err = ipt.AppendUnique("filter", chain, "-s", subnet1, "-d", address1, "-j", "ACCEPT")
  229. if err != nil {
  230. t.Fatalf("AppendUnique failed: %v", err)
  231. }
  232. err = ipt.Append("filter", chain, "-s", subnet2, "-d", address1, "-j", "ACCEPT")
  233. if err != nil {
  234. t.Fatalf("Append failed: %v", err)
  235. }
  236. err = ipt.Insert("filter", chain, 2, "-s", subnet2, "-d", address2, "-j", "ACCEPT")
  237. if err != nil {
  238. t.Fatalf("Insert failed: %v", err)
  239. }
  240. err = ipt.Insert("filter", chain, 1, "-s", subnet1, "-d", address2, "-j", "ACCEPT")
  241. if err != nil {
  242. t.Fatalf("Insert failed: %v", err)
  243. }
  244. err = ipt.Delete("filter", chain, "-s", subnet1, "-d", address2, "-j", "ACCEPT")
  245. if err != nil {
  246. t.Fatalf("Delete failed: %v", err)
  247. }
  248. err = ipt.Append("filter", chain, "-s", address1, "-d", subnet2, "-j", "ACCEPT")
  249. if err != nil {
  250. t.Fatalf("Append failed: %v", err)
  251. }
  252. rules, err := ipt.List("filter", chain)
  253. if err != nil {
  254. t.Fatalf("List failed: %v", err)
  255. }
  256. expected := []string{
  257. "-N " + chain,
  258. "-A " + chain + " -s " + subnet1 + " -d " + address1 + " -j ACCEPT",
  259. "-A " + chain + " -s " + subnet2 + " -d " + address2 + " -j ACCEPT",
  260. "-A " + chain + " -s " + subnet2 + " -d " + address1 + " -j ACCEPT",
  261. "-A " + chain + " -s " + address1 + " -d " + subnet2 + " -j ACCEPT",
  262. }
  263. if !reflect.DeepEqual(rules, expected) {
  264. t.Fatalf("List mismatch: \ngot %#v \nneed %#v", rules, expected)
  265. }
  266. rules, err = ipt.ListWithCounters("filter", chain)
  267. if err != nil {
  268. t.Fatalf("ListWithCounters failed: %v", err)
  269. }
  270. suffix := " -c 0 0 -j ACCEPT"
  271. if ipt.mode == "nf_tables" {
  272. suffix = " -j ACCEPT -c 0 0"
  273. }
  274. expected = []string{
  275. "-N " + chain,
  276. "-A " + chain + " -s " + subnet1 + " -d " + address1 + suffix,
  277. "-A " + chain + " -s " + subnet2 + " -d " + address2 + suffix,
  278. "-A " + chain + " -s " + subnet2 + " -d " + address1 + suffix,
  279. "-A " + chain + " -s " + address1 + " -d " + subnet2 + suffix,
  280. }
  281. if !reflect.DeepEqual(rules, expected) {
  282. t.Fatalf("ListWithCounters mismatch: \ngot %#v \nneed %#v", rules, expected)
  283. }
  284. stats, err := ipt.Stats("filter", chain)
  285. if err != nil {
  286. t.Fatalf("Stats failed: %v", err)
  287. }
  288. opt := "--"
  289. if ipt.proto == ProtocolIPv6 {
  290. opt = " "
  291. }
  292. expectedStats := [][]string{
  293. {"0", "0", "ACCEPT", "all", opt, "*", "*", subnet1, address1, ""},
  294. {"0", "0", "ACCEPT", "all", opt, "*", "*", subnet2, address2, ""},
  295. {"0", "0", "ACCEPT", "all", opt, "*", "*", subnet2, address1, ""},
  296. {"0", "0", "ACCEPT", "all", opt, "*", "*", address1, subnet2, ""},
  297. }
  298. if !reflect.DeepEqual(stats, expectedStats) {
  299. t.Fatalf("Stats mismatch: \ngot %#v \nneed %#v", stats, expectedStats)
  300. }
  301. structStats, err := ipt.StructuredStats("filter", chain)
  302. if err != nil {
  303. t.Fatalf("StructuredStats failed: %v", err)
  304. }
  305. // It's okay to not check the following errors as they will be evaluated
  306. // in the subsequent usage
  307. _, address1CIDR, _ := net.ParseCIDR(address1)
  308. _, address2CIDR, _ := net.ParseCIDR(address2)
  309. _, subnet1CIDR, _ := net.ParseCIDR(subnet1)
  310. _, subnet2CIDR, _ := net.ParseCIDR(subnet2)
  311. expectedStructStats := []Stat{
  312. {0, 0, "ACCEPT", "all", opt, "*", "*", subnet1CIDR, address1CIDR, ""},
  313. {0, 0, "ACCEPT", "all", opt, "*", "*", subnet2CIDR, address2CIDR, ""},
  314. {0, 0, "ACCEPT", "all", opt, "*", "*", subnet2CIDR, address1CIDR, ""},
  315. {0, 0, "ACCEPT", "all", opt, "*", "*", address1CIDR, subnet2CIDR, ""},
  316. }
  317. if !reflect.DeepEqual(structStats, expectedStructStats) {
  318. t.Fatalf("StructuredStats mismatch: \ngot %#v \nneed %#v",
  319. structStats, expectedStructStats)
  320. }
  321. for i, stat := range expectedStats {
  322. stat, err := ipt.ParseStat(stat)
  323. if err != nil {
  324. t.Fatalf("ParseStat failed: %v", err)
  325. }
  326. if !reflect.DeepEqual(stat, expectedStructStats[i]) {
  327. t.Fatalf("ParseStat mismatch: \ngot %#v \nneed %#v",
  328. stat, expectedStructStats[i])
  329. }
  330. }
  331. err = ipt.DeleteIfExists("filter", chain, "-s", address1, "-d", subnet2, "-j", "ACCEPT")
  332. if err != nil {
  333. t.Fatalf("DeleteIfExists failed for existing rule: %v", err)
  334. }
  335. err = ipt.DeleteIfExists("filter", chain, "-s", address1, "-d", subnet2, "-j", "ACCEPT")
  336. if err != nil {
  337. t.Fatalf("DeleteIfExists failed for non-existing rule: %v", err)
  338. }
  339. // Clear the chain that was created.
  340. err = ipt.ClearChain("filter", chain)
  341. if err != nil {
  342. t.Fatalf("Failed to clear test chain: %v", err)
  343. }
  344. // Delete the chain that was created
  345. err = ipt.DeleteChain("filter", chain)
  346. if err != nil {
  347. t.Fatalf("Failed to delete test chain: %v", err)
  348. }
  349. }
  350. // TestError checks that we're OK when iptables fails to execute
  351. func TestError(t *testing.T) {
  352. ipt, err := New()
  353. if err != nil {
  354. t.Fatalf("failed to init: %v", err)
  355. }
  356. chain := randChain(t)
  357. _, err = ipt.List("filter", chain)
  358. if err == nil {
  359. t.Fatalf("no error with invalid params")
  360. }
  361. switch e := err.(type) {
  362. case *Error:
  363. // OK
  364. default:
  365. t.Fatalf("expected type iptables.Error, got %t", e)
  366. }
  367. // Now set an invalid binary path
  368. ipt.path = "/does-not-exist"
  369. _, err = ipt.ListChains("filter")
  370. if err == nil {
  371. t.Fatalf("no error with invalid ipt binary")
  372. }
  373. switch e := err.(type) {
  374. case *os.PathError:
  375. // OK
  376. default:
  377. t.Fatalf("expected type os.PathError, got %t", e)
  378. }
  379. }
  380. func TestIsNotExist(t *testing.T) {
  381. ipt, err := New()
  382. if err != nil {
  383. t.Fatalf("failed to init: %v", err)
  384. }
  385. // Create a chain, add a rule
  386. chainName := randChain(t)
  387. err = ipt.NewChain("filter", chainName)
  388. if err != nil {
  389. t.Fatal(err)
  390. }
  391. defer func() {
  392. ipt.ClearChain("filter", chainName)
  393. ipt.DeleteChain("filter", chainName)
  394. }()
  395. err = ipt.Append("filter", chainName, "-p", "tcp", "-j", "DROP")
  396. if err != nil {
  397. t.Fatal(err)
  398. }
  399. // Delete rule twice
  400. err = ipt.Delete("filter", chainName, "-p", "tcp", "-j", "DROP")
  401. if err != nil {
  402. t.Fatal(err)
  403. }
  404. err = ipt.Delete("filter", chainName, "-p", "tcp", "-j", "DROP")
  405. if err == nil {
  406. t.Fatal("delete twice got no error...")
  407. }
  408. e, ok := err.(*Error)
  409. if !ok {
  410. t.Fatalf("Got wrong error type, expected iptables.Error, got %T", err)
  411. }
  412. if !e.IsNotExist() {
  413. t.Fatal("IsNotExist returned false, expected true")
  414. }
  415. // Delete chain
  416. err = ipt.DeleteChain("filter", chainName)
  417. if err != nil {
  418. t.Fatal(err)
  419. }
  420. err = ipt.DeleteChain("filter", chainName)
  421. if err == nil {
  422. t.Fatal("deletechain twice got no error...")
  423. }
  424. e, ok = err.(*Error)
  425. if !ok {
  426. t.Fatalf("Got wrong error type, expected iptables.Error, got %T", err)
  427. }
  428. if !e.IsNotExist() {
  429. t.Fatal("IsNotExist returned false, expected true")
  430. }
  431. // iptables may add more logs to the errors msgs
  432. e.msg = "Another app is currently holding the xtables lock; waiting (1s) for it to exit..." + e.msg
  433. if !e.IsNotExist() {
  434. t.Fatal("IsNotExist returned false, expected true")
  435. }
  436. }
  437. func TestIsNotExistForIPv6(t *testing.T) {
  438. ipt, err := NewWithProtocol(ProtocolIPv6)
  439. if err != nil {
  440. t.Fatalf("failed to init: %v", err)
  441. }
  442. // Create a chain, add a rule
  443. chainName := randChain(t)
  444. err = ipt.NewChain("filter", chainName)
  445. if err != nil {
  446. t.Fatal(err)
  447. }
  448. defer func() {
  449. ipt.ClearChain("filter", chainName)
  450. ipt.DeleteChain("filter", chainName)
  451. }()
  452. err = ipt.Append("filter", chainName, "-p", "tcp", "-j", "DROP")
  453. if err != nil {
  454. t.Fatal(err)
  455. }
  456. // Delete rule twice
  457. err = ipt.Delete("filter", chainName, "-p", "tcp", "-j", "DROP")
  458. if err != nil {
  459. t.Fatal(err)
  460. }
  461. err = ipt.Delete("filter", chainName, "-p", "tcp", "-j", "DROP")
  462. if err == nil {
  463. t.Fatal("delete twice got no error...")
  464. }
  465. e, ok := err.(*Error)
  466. if !ok {
  467. t.Fatalf("Got wrong error type, expected iptables.Error, got %T", err)
  468. }
  469. if !e.IsNotExist() {
  470. t.Fatal("IsNotExist returned false, expected true")
  471. }
  472. // Delete chain
  473. err = ipt.DeleteChain("filter", chainName)
  474. if err != nil {
  475. t.Fatal(err)
  476. }
  477. err = ipt.DeleteChain("filter", chainName)
  478. if err == nil {
  479. t.Fatal("deletechain twice got no error...")
  480. }
  481. e, ok = err.(*Error)
  482. if !ok {
  483. t.Fatalf("Got wrong error type, expected iptables.Error, got %T", err)
  484. }
  485. if !e.IsNotExist() {
  486. t.Fatal("IsNotExist returned false, expected true")
  487. }
  488. // iptables may add more logs to the errors msgs
  489. e.msg = "Another app is currently holding the xtables lock; waiting (1s) for it to exit..." + e.msg
  490. if !e.IsNotExist() {
  491. t.Fatal("IsNotExist returned false, expected true")
  492. }
  493. }
  494. func TestFilterRuleOutput(t *testing.T) {
  495. testCases := []struct {
  496. name string
  497. in string
  498. out string
  499. }{
  500. {
  501. "legacy output",
  502. "-A foo1 -p tcp -m tcp --dport 1337 -j ACCEPT",
  503. "-A foo1 -p tcp -m tcp --dport 1337 -j ACCEPT",
  504. },
  505. {
  506. "nft output",
  507. "[99:42] -A foo1 -p tcp -m tcp --dport 1337 -j ACCEPT",
  508. "-A foo1 -p tcp -m tcp --dport 1337 -j ACCEPT -c 99 42",
  509. },
  510. }
  511. for _, tt := range testCases {
  512. t.Run(tt.name, func(t *testing.T) {
  513. actual := filterRuleOutput(tt.in)
  514. if actual != tt.out {
  515. t.Fatalf("expect %s actual %s", tt.out, actual)
  516. }
  517. })
  518. }
  519. }
  520. func TestExtractIptablesVersion(t *testing.T) {
  521. testCases := []struct {
  522. in string
  523. v1, v2, v3 int
  524. mode string
  525. err bool
  526. }{
  527. {
  528. "iptables v1.8.0 (nf_tables)",
  529. 1, 8, 0,
  530. "nf_tables",
  531. false,
  532. },
  533. {
  534. "iptables v1.8.0 (legacy)",
  535. 1, 8, 0,
  536. "legacy",
  537. false,
  538. },
  539. {
  540. "iptables v1.6.2",
  541. 1, 6, 2,
  542. "legacy",
  543. false,
  544. },
  545. }
  546. for i, tt := range testCases {
  547. t.Run(fmt.Sprint(i), func(t *testing.T) {
  548. v1, v2, v3, mode, err := extractIptablesVersion(tt.in)
  549. if err == nil && tt.err {
  550. t.Fatal("expected err, got none")
  551. } else if err != nil && !tt.err {
  552. t.Fatalf("unexpected err %s", err)
  553. }
  554. if v1 != tt.v1 || v2 != tt.v2 || v3 != tt.v3 || mode != tt.mode {
  555. t.Fatalf("expected %d %d %d %s, got %d %d %d %s",
  556. tt.v1, tt.v2, tt.v3, tt.mode,
  557. v1, v2, v3, mode)
  558. }
  559. })
  560. }
  561. }