Lines Matching refs:gwj
459 struct cgw_job *gwj = (struct cgw_job *)data;
465 if (gwj->flags & CGW_FLAGS_CAN_FD) {
490 gwj->deleted_frames++;
494 if (!(gwj->dst.dev->flags & IFF_UP)) {
495 gwj->dropped_frames++;
500 if (!(gwj->flags & CGW_FLAGS_CAN_IIF_TX_OK) &&
501 can_skb_prv(skb)->ifindex == gwj->dst.dev->ifindex)
509 if (gwj->mod.modfunc[0])
515 gwj->dropped_frames++;
523 if (gwj->limit_hops && cgw_hops(nskb) == 1)
524 cgw_hops(nskb) = max_hops - gwj->limit_hops + 1;
526 nskb->dev = gwj->dst.dev;
532 while (modidx < MAX_MODFUNCTIONS && gwj->mod.modfunc[modidx])
533 (*gwj->mod.modfunc[modidx++])(cf, &gwj->mod);
543 gwj->deleted_frames++;
549 if (gwj->mod.csumfunc.crc8)
550 (*gwj->mod.csumfunc.crc8)(cf, &gwj->mod.csum.crc8);
552 if (gwj->mod.csumfunc.xor)
553 (*gwj->mod.csumfunc.xor)(cf, &gwj->mod.csum.xor);
557 if (!(gwj->flags & CGW_FLAGS_CAN_SRC_TSTAMP))
561 if (can_send(nskb, gwj->flags & CGW_FLAGS_CAN_ECHO))
562 gwj->dropped_frames++;
564 gwj->handled_frames++;
567 static inline int cgw_register_filter(struct net *net, struct cgw_job *gwj)
569 return can_rx_register(net, gwj->src.dev, gwj->ccgw.filter.can_id,
570 gwj->ccgw.filter.can_mask, can_can_gw_rcv,
571 gwj, "gw", NULL);
574 static inline void cgw_unregister_filter(struct net *net, struct cgw_job *gwj)
576 can_rx_unregister(net, gwj->src.dev, gwj->ccgw.filter.can_id,
577 gwj->ccgw.filter.can_mask, can_can_gw_rcv, gwj);
582 struct cgw_job *gwj = container_of(rcu_head, struct cgw_job, rcu);
584 kmem_cache_free(cgw_cache, gwj);
597 struct cgw_job *gwj = NULL;
602 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
603 if (gwj->src.dev == dev || gwj->dst.dev == dev) {
604 hlist_del(&gwj->list);
605 cgw_unregister_filter(net, gwj);
606 call_rcu(&gwj->rcu, cgw_job_free_rcu);
614 static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj, int type,
626 rtcan->gwtype = gwj->gwtype;
627 rtcan->flags = gwj->flags;
631 if (gwj->handled_frames) {
632 if (nla_put_u32(skb, CGW_HANDLED, gwj->handled_frames) < 0)
636 if (gwj->dropped_frames) {
637 if (nla_put_u32(skb, CGW_DROPPED, gwj->dropped_frames) < 0)
641 if (gwj->deleted_frames) {
642 if (nla_put_u32(skb, CGW_DELETED, gwj->deleted_frames) < 0)
648 if (gwj->limit_hops) {
649 if (nla_put_u8(skb, CGW_LIM_HOPS, gwj->limit_hops) < 0)
653 if (gwj->flags & CGW_FLAGS_CAN_FD) {
656 if (gwj->mod.modtype.and) {
657 memcpy(&mb.cf, &gwj->mod.modframe.and, sizeof(mb.cf));
658 mb.modtype = gwj->mod.modtype.and;
663 if (gwj->mod.modtype.or) {
664 memcpy(&mb.cf, &gwj->mod.modframe.or, sizeof(mb.cf));
665 mb.modtype = gwj->mod.modtype.or;
670 if (gwj->mod.modtype.xor) {
671 memcpy(&mb.cf, &gwj->mod.modframe.xor, sizeof(mb.cf));
672 mb.modtype = gwj->mod.modtype.xor;
677 if (gwj->mod.modtype.set) {
678 memcpy(&mb.cf, &gwj->mod.modframe.set, sizeof(mb.cf));
679 mb.modtype = gwj->mod.modtype.set;
686 if (gwj->mod.modtype.and) {
687 memcpy(&mb.cf, &gwj->mod.modframe.and, sizeof(mb.cf));
688 mb.modtype = gwj->mod.modtype.and;
693 if (gwj->mod.modtype.or) {
694 memcpy(&mb.cf, &gwj->mod.modframe.or, sizeof(mb.cf));
695 mb.modtype = gwj->mod.modtype.or;
700 if (gwj->mod.modtype.xor) {
701 memcpy(&mb.cf, &gwj->mod.modframe.xor, sizeof(mb.cf));
702 mb.modtype = gwj->mod.modtype.xor;
707 if (gwj->mod.modtype.set) {
708 memcpy(&mb.cf, &gwj->mod.modframe.set, sizeof(mb.cf));
709 mb.modtype = gwj->mod.modtype.set;
715 if (gwj->mod.uid) {
716 if (nla_put_u32(skb, CGW_MOD_UID, gwj->mod.uid) < 0)
720 if (gwj->mod.csumfunc.crc8) {
722 &gwj->mod.csum.crc8) < 0)
726 if (gwj->mod.csumfunc.xor) {
728 &gwj->mod.csum.xor) < 0)
732 if (gwj->gwtype == CGW_TYPE_CAN_CAN) {
733 if (gwj->ccgw.filter.can_id || gwj->ccgw.filter.can_mask) {
735 &gwj->ccgw.filter) < 0)
739 if (nla_put_u32(skb, CGW_SRC_IF, gwj->ccgw.src_idx) < 0)
742 if (nla_put_u32(skb, CGW_DST_IF, gwj->ccgw.dst_idx) < 0)
758 struct cgw_job *gwj = NULL;
763 hlist_for_each_entry_rcu(gwj, &net->can.cgw_list, list) {
767 if (cgw_put_job(skb, gwj, RTM_NEWROUTE,
1061 struct cgw_job *gwj;
1089 hlist_for_each_entry(gwj, &net->can.cgw_list, list) {
1090 if (gwj->mod.uid != mod.uid)
1094 if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw)))
1099 memcpy(&gwj->mod, &mod, sizeof(mod));
1109 gwj = kmem_cache_alloc(cgw_cache, GFP_KERNEL);
1110 if (!gwj)
1113 gwj->handled_frames = 0;
1114 gwj->dropped_frames = 0;
1115 gwj->deleted_frames = 0;
1116 gwj->flags = r->flags;
1117 gwj->gwtype = r->gwtype;
1118 gwj->limit_hops = limhops;
1121 memcpy(&gwj->mod, &mod, sizeof(mod));
1122 memcpy(&gwj->ccgw, &ccgw, sizeof(ccgw));
1126 gwj->src.dev = __dev_get_by_index(net, gwj->ccgw.src_idx);
1128 if (!gwj->src.dev)
1131 if (gwj->src.dev->type != ARPHRD_CAN)
1134 gwj->dst.dev = __dev_get_by_index(net, gwj->ccgw.dst_idx);
1136 if (!gwj->dst.dev)
1139 if (gwj->dst.dev->type != ARPHRD_CAN)
1143 if (gwj->src.dev == gwj->dst.dev &&
1144 !(gwj->flags & CGW_FLAGS_CAN_IIF_TX_OK)) {
1151 err = cgw_register_filter(net, gwj);
1153 hlist_add_head_rcu(&gwj->list, &net->can.cgw_list);
1156 kmem_cache_free(cgw_cache, gwj);
1163 struct cgw_job *gwj = NULL;
1168 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
1169 hlist_del(&gwj->list);
1170 cgw_unregister_filter(net, gwj);
1171 call_rcu(&gwj->rcu, cgw_job_free_rcu);
1179 struct cgw_job *gwj = NULL;
1216 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
1217 if (gwj->flags != r->flags)
1220 if (gwj->limit_hops != limhops)
1224 if (gwj->mod.uid || mod.uid) {
1225 if (gwj->mod.uid != mod.uid)
1229 if (memcmp(&gwj->mod, &mod, sizeof(mod)))
1234 if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw)))
1237 hlist_del(&gwj->list);
1238 cgw_unregister_filter(net, gwj);
1239 call_rcu(&gwj->rcu, cgw_job_free_rcu);