ematch.c (5a84d159061d914c8dd4aa372ac6e9529c2be453) | ematch.c (27a884dc3cb63b93c2b3b643f5b31eed5f8a4d26) |
---|---|
1/* 2 * net/sched/ematch.c Extended Match API 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 404 unchanged lines hidden (view full) --- 413 * This function dumps a ematch tree into a rtnl message. It is valid to 414 * call this function while the ematch tree is in use. 415 * 416 * Returns -1 if the skb tailroom is insufficient. 417 */ 418int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) 419{ 420 int i; | 1/* 2 * net/sched/ematch.c Extended Match API 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 404 unchanged lines hidden (view full) --- 413 * This function dumps a ematch tree into a rtnl message. It is valid to 414 * call this function while the ematch tree is in use. 415 * 416 * Returns -1 if the skb tailroom is insufficient. 417 */ 418int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) 419{ 420 int i; |
421 struct rtattr * top_start = (struct rtattr*) skb->tail; 422 struct rtattr * list_start; | 421 u8 *tail; 422 struct rtattr *top_start = (struct rtattr *)skb_tail_pointer(skb); 423 struct rtattr *list_start; |
423 424 RTA_PUT(skb, tlv, 0, NULL); 425 RTA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr); 426 | 424 425 RTA_PUT(skb, tlv, 0, NULL); 426 RTA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr); 427 |
427 list_start = (struct rtattr *) skb->tail; | 428 list_start = (struct rtattr *)skb_tail_pointer(skb); |
428 RTA_PUT(skb, TCA_EMATCH_TREE_LIST, 0, NULL); 429 | 429 RTA_PUT(skb, TCA_EMATCH_TREE_LIST, 0, NULL); 430 |
431 tail = skb_tail_pointer(skb); |
|
430 for (i = 0; i < tree->hdr.nmatches; i++) { | 432 for (i = 0; i < tree->hdr.nmatches; i++) { |
431 struct rtattr *match_start = (struct rtattr*) skb->tail; | 433 struct rtattr *match_start = (struct rtattr *)tail; |
432 struct tcf_ematch *em = tcf_em_get_match(tree, i); 433 struct tcf_ematch_hdr em_hdr = { 434 .kind = em->ops ? em->ops->kind : TCF_EM_CONTAINER, 435 .matchid = em->matchid, 436 .flags = em->flags 437 }; 438 439 RTA_PUT(skb, i+1, sizeof(em_hdr), &em_hdr); 440 441 if (em->ops && em->ops->dump) { 442 if (em->ops->dump(skb, em) < 0) 443 goto rtattr_failure; 444 } else if (tcf_em_is_container(em) || tcf_em_is_simple(em)) { 445 u32 u = em->data; 446 RTA_PUT_NOHDR(skb, sizeof(u), &u); 447 } else if (em->datalen > 0) 448 RTA_PUT_NOHDR(skb, em->datalen, (void *) em->data); 449 | 434 struct tcf_ematch *em = tcf_em_get_match(tree, i); 435 struct tcf_ematch_hdr em_hdr = { 436 .kind = em->ops ? em->ops->kind : TCF_EM_CONTAINER, 437 .matchid = em->matchid, 438 .flags = em->flags 439 }; 440 441 RTA_PUT(skb, i+1, sizeof(em_hdr), &em_hdr); 442 443 if (em->ops && em->ops->dump) { 444 if (em->ops->dump(skb, em) < 0) 445 goto rtattr_failure; 446 } else if (tcf_em_is_container(em) || tcf_em_is_simple(em)) { 447 u32 u = em->data; 448 RTA_PUT_NOHDR(skb, sizeof(u), &u); 449 } else if (em->datalen > 0) 450 RTA_PUT_NOHDR(skb, em->datalen, (void *) em->data); 451 |
450 match_start->rta_len = skb->tail - (u8*) match_start; | 452 tail = skb_tail_pointer(skb); 453 match_start->rta_len = tail - (u8 *)match_start; |
451 } 452 | 454 } 455 |
453 list_start->rta_len = skb->tail - (u8 *) list_start; 454 top_start->rta_len = skb->tail - (u8 *) top_start; | 456 list_start->rta_len = tail - (u8 *)list_start; 457 top_start->rta_len = tail - (u8 *)top_start; |
455 456 return 0; 457 458rtattr_failure: 459 return -1; 460} 461 462static inline int tcf_em_match(struct sk_buff *skb, struct tcf_ematch *em, --- 62 unchanged lines hidden --- | 458 459 return 0; 460 461rtattr_failure: 462 return -1; 463} 464 465static inline int tcf_em_match(struct sk_buff *skb, struct tcf_ematch *em, --- 62 unchanged lines hidden --- |